too many output arguments

조회 수: 135 (최근 30일)
Matthew Fernez
Matthew Fernez 2017년 4월 27일
답변: Sindhuja Parimalarangan 2017년 5월 1일
q=1;
Cbi=0;
V=60;
C1=5*10^3;
C2=1*10^6;
E1=1*10^4;
E2=1.5*10^4;
dh=-5000;
p=1;
Cp=1000;
Ca=x(1);
Cb=x(2);
T=x(3);
k1=C1*exp^(-E1/(R*T));
k2=C2*exp^(-E2/(R*T));
f(1)=(q/V)*(Cai-Ca)-k1*Ca+k2*Cb;
f(2)=(q/V)*(Cbi-Cb)+k1*Ca-k2*Cb;
f(3)=(q/V)*(Ti-T)+(dh/(p*Cp))*(k1*Ca-k2*Cb);
I have Cai and Ti defined in my workspace. When I run fsolve on this function it comes up as too many output arguments. any ideas??
  댓글 수: 2
Star Strider
Star Strider 2017년 4월 27일
‘When I run fsolve on this function it comes up as too many output arguments. any ideas??’
Yes!
Since the problem seems to be with your function and your call to fsolve, posting your complete function and your fsolve call will be necessary to understand it.
KSSV
KSSV 2017년 4월 28일
It says, you are trying to extract more number of outputs which fsolve gives. We cannot help you unless complete code is shown.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sindhuja Parimalarangan
Sindhuja Parimalarangan 2017년 5월 1일
A function you are trying to call expects fewer input/output arguments than you have provided it
Here are some possible causes:
1) You have tried to obtain two or more outputs from a function that only returns one.
2) You have multiple functions with the same name. One possible way when this can happen is when you create a function with the same name as an in-built MATLAB function. To identify which function is being called by MATLAB, use the WHICH command as follows:
which -all <function-name>
3) You edited your function and increased the number of input arguments but didn't click save on the editor for that function , then while trying to call this function from your main function, you are getting this error.
Debugging steps :
1) Stop MATLAB on the line where the error occurs. Verify that you have specified the correct number of input and/or output arguments
2) Another way to debug this problem is to use the NARGIN and NARGOUT functions. When you call NARGIN or NARGOUT inside a function, it returns how many inputs or outputs are actually specified in the call to the function.
3) Finally, using the DBTYPE function in the following syntax
dbtype 'FunctionName' 1
This will display the first line of the MATLAB function file, which can be useful for viewing the input and output arguments that the function expects.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by