![]() |
沿对角线在矩阵上的矢量投影
有一个简单的方法如何产生以下矩阵:
a = 4 5 6 7 3 4 5 6 2 3 4 5 1 2 3 4 向量[1 2 3 4 5 6 7]沿对角线的投影是什么? 谢谢 [B]回答:[/B] 您可以使用函数[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/hankel.html"]HANKEL[/URL]和[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/flipud.html"]FLIPUD[/URL]进行此操作: a = flipud(hankel(1:4,4:7)); 或使用功能[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/toeplitz.html"]TOEPLITZ[/URL]和[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fliplr.html"]FLIPLR[/URL] : a = toeplitz(fliplr(1:4),4:7); a = toeplitz(4:-1:1,4:7); %# Without fliplr 您还可以将这些解决方案推广到任意矢量,在该矢量中您选择了要中断矢量的中心点。例如: >> vec = [6 3 45 1 1 2]; %# A sample vector >> centerIndex = 3; >> a = flipud(hankel(vec(1:centerIndex),vec(centerIndex:end))) a = 45 1 1 2 3 45 1 1 6 3 45 1 上面的示例将向量的前三个元素放在第一列,并将向量的最后四个元素放在第一行。 [url=https://stackoverflow.com/questions/2594429]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 02:58。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.