matlab - Output argument "am" (and maybe others) not assigned during call to -
i trying use function in m file error(mentioned in question). seems correct , a, b , c defined in m file. thoughts? error: error in modal2 (line 8) [v,an]=eig(a); output argument "am" (and maybe others) not assigned during call "c:\users\cena\desktop\thesis\my codes\smc\modal2.m>modal2".
function [r,am,bm,cm] = modal2(a,b,c) % function determines modal representation 2(am,bm,cm) %given generic state-space representation (a,b,c) %and transformation r modal representation %such am=inv(r)*a*r, bm=inv(r)*b , cm=c*r %transformation complex-diagonal form: [v,an]=eig(a); bn=inv(v)*b; cn=c*v; %transformation modal form 2: = find(imag(diag(an))'); index = i(1:2:length(i)); j=sqrt(-1); t = eye(length(an)); if isempty(index) am=an;bm=bn;cm=cn; else i=index t(i:i+1,i:i+1)=[j 1;-j 1]; end %modal transformation r=v*t; end
the problem in
if isempty(index) am=an;bm=bn;cm=cn;
the assignment variables being done if conditional passes. if doesn't , there no assignment.
you need modify code assign variables under conditions if going output arguments.
Comments
Post a Comment