필터 지우기
필터 지우기

Function outputs a 1x2 matrix, yet I can't append that matrix to another matrix.

조회 수: 1 (최근 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)

채택된 답변

Daniel Shub
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개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by