首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调用期间未分配输出参数"am“(可能还有其他参数)

调用期间未分配输出参数"am“(可能还有其他参数)
EN

Stack Overflow用户
提问于 2015-06-14 17:51:02
回答 1查看 1.5K关注 0票数 1

我试图在我的m文件中使用这个函数,但我得到了一个错误(在问题中提到)。一切似乎都是正确的,a,b和c都在我的m文件中定义了。有什么想法吗?错误:Error in modal2 (line 8) [v,an]=eig(a); Output argument "am" (and maybe others) not assigned during call to "C:\Users\Cena\Desktop\Thesis\My Codes\SMC\modal2.m>modal2".

代码语言:javascript
复制
function [r,am,bm,cm] = modal2(a,b,c)
% this function determines the modal representation 2(am,bm,cm)
%given a generic state-space representation (a,b,c)
%and the transformation r to the modal representation
%such that am=inv(r)*a*r, bm=inv(r)*b and cm=c*r

%transformation to complex-diagonal form:
[v,an]=eig(a);
bn=inv(v)*b;
cn=c*v;

%transformation to modal form 2:
i = 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
   for i=index
        t(i:i+1,i:i+1)=[j 1;-j 1];
end
%Modal transformation
    r=v*t;
end
EN

回答 1

Stack Overflow用户

发布于 2015-06-14 21:35:05

问题很可能出现在

代码语言:javascript
复制
if isempty(index)
   am=an;bm=bn;cm=cn;

只有在条件通过的情况下,才会对这些变量进行赋值。如果没有,就没有赋值。

如果要将这些变量作为输出参数,则需要修改代码以在所有条件下将其赋值给这些变量。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30827993

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档