这是计算奈奎斯特稳定性标准的函数的一部分。re
当向量或im
没有五个元素时,函数会出错:
尝试访问 im(5);索引超出范围,因为 numel(im)=4。稳定性错误(第 27 行) tran(w) = re(1) + re(2)*w.^1 + re(3)*w.^2 + re(4)*w.^3 + re(5 ) w.^4 +1i (...
我想分配0
给缺失的元素。
function answear=stability(re,im)
%% Function check stability of system
%re is real part of transmitation
%im is imagine part of transmitation
%% data
for n=1:length(re)
if(re(n) == [ ])
re(n) = 0;
end
end
for n=1:length(im)
if(im (n)== [ ])
im(n) = 0;
end
end
if( length(re) > length(im))
root = length(re);
else
root = length(im);
end
for w=1:root
tran(w) = re(1) + re(2)*w.^1 + re(3)*w.^2 + re(4)*w.^3 + re(5)*w.^4 +1i*(...
im(1) + im(2)*w.^1 + im(3)*w.^2 + im(4)*w.^3 +im(5)*w.^4);
end