Function outputs a 1x2 matrix, yet I can't append that matrix to another matrix.
2 次查看(过去 30 天)
显示 更早的评论
function prop(f,u,q,sq)
%Define stuff
SQ=[];
Q=[];
g=size(q);
%Evaluation of f with q
Q=subs(f,u,q);
%Uncertainty
for h=1:g(1,2);
Sq=subs(((diff(f,u(1,h)))^2*sq(1,h)^2),u,q);
SQ=sqrt(sum([SQ Sq]));
end
[Q SQ]
end
The function requires for f a symbolic function, u a row vector with all the variables being used in f, q a row vector that contains values for these variables and sq also some values. (so a symbolic function with n variables and then three 1 x n row vectors). For example f=u1+u2, u=[u1 u2], q=[1 2] and sq=[0.1 0.2].
It outputs a 1x2 matrix, yet when I try
A=[]
A=[A prop(f,u,[1 2],[0.1 0.2])]
I get "??? Error using ==> prop Too many output arguments."
How can I fix this? I need the output of this function to be used in another function which uses this function multiple times for varying q vectors (and then adding the varying output 1x2 vectors to one big vector)
0 个评论
采纳的回答
Daniel Shub
2011-11-26
You need to change the first line to:
function A = prop(f,u,q,sq)
and the second to last line to
A = [Q SQ]
You can use any name you want for A.
Depending on what Q and SQ are (potentially they are symbolic), then you may need to initialize A to be something else in your main script
A = sym.empty(0, 2);
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!