Matlab的esort.m的替代函数
我需要对从[Ev,Ed]=eig a获得的特征向量Ev的向量进行降序排序。我还需要排序中使用的索引 我不能使用esort.m,它与控制系统工具箱一起提供,我没有,也无法获得。是否有esort.m的替代函数可供我使用 谢谢 使用函数sort、real和imag,您可以复制esort函数:Matlab的esort.m的替代函数,matlab,Matlab,我需要对从[Ev,Ed]=eig a获得的特征向量Ev的向量进行降序排序。我还需要排序中使用的索引 我不能使用esort.m,它与控制系统工具箱一起提供,我没有,也无法获得。是否有esort.m的替代函数可供我使用 谢谢 使用函数sort、real和imag,您可以复制esort函数: imre = rand(10,1)+rand(10,1)*1i; %random imaginary number re = real(imre); %extract the r
imre = rand(10,1)+rand(10,1)*1i; %random imaginary number
re = real(imre); %extract the real part
im = imag(imre)*1i; %extract the imaginary part
[sorted,ind] = sort(re); %sort according to the real part
imre_sort = sorted+im(ind); %add the imaginary part.
简单地说,函数类似于:
function imre_sort = todelete(imre,ord)
%ord can be 'ascend' or 'descend'
if nargin == 1
ord = 'ascend';
end
re = real(imre);
im = imag(imre)*1i;
[sorted,ind] = sort(re,ord);
imre_sort = sorted+im(ind);
end