Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.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的esort.m的替代函数_Matlab - Fatal编程技术网

Matlab的esort.m的替代函数

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

我需要对从[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 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