Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Matlab中翻转向量,如1:10到10:1?_Matlab_Math - Fatal编程技术网

如何在Matlab中翻转向量,如1:10到10:1?

如何在Matlab中翻转向量,如1:10到10:1?,matlab,math,Matlab,Math,假设我有'123'。我想得到'3 2 1'。如何在Matlab中获得它 更详细的示例 N=64; [x y]=meshgrid(linspace(-3*pi,3*pi,N),linspace(-3*pi,3*pi,N)); t=sqrt(x.^2+y.^2); % Now instead of "f=t+2*sinc(t);", I want to get all elements inverted aka % first element becomes the last and so on

假设我有
'123'
。我想得到
'3 2 1'
。如何在Matlab中获得它

更详细的示例

N=64;
[x y]=meshgrid(linspace(-3*pi,3*pi,N),linspace(-3*pi,3*pi,N));
t=sqrt(x.^2+y.^2);

% Now instead of "f=t+2*sinc(t);", I want to get all elements inverted aka 
% first element becomes the last and so on -- I thought it would be 
% sinc(abs(length(t)-t)) but it is not.

使用MATLAB函数。

值得注意的是,它只对行向量有效。相反,需要一个列向量。另外,一个更一般的方法是
x(end:-1:1)
。我想你的意思是
[1 2 3]
而不是
'1 2 3'
作为你的出发点-但事实上,下面的解决方案同样适用于这两种方法。在你的问题示例中,
sinc
f
都是对称函数,即
sinc(-x)=sinc(x) 
,其中
x
是一些正数等,因此通过
fliplr
翻转向量不会改变结果。