I'm trying to write a script file that compares the data from two different function files. As soon as I attempt to plot the data I get the error message "too many output arguments'. Why?

The function files run fine separately, and they return the correct values when i run the script file. However it can't seem to plot the values, I've attempted to name the values returned by the separate functions but it doesn't help. e.g
T=20:10:150;
[r1] = MyFunction1(T);
[r2] = MyFunction2(T);
subplot(2,1,1)
plot(T,r1)
subplot(2,1,2)
plot(T,r2)

4 commentaires

Soho - what can you tell us about the data types and dimensions of r1 and r2? Which line generates the error - the first call to plot or the second? It isn't clear why the error message is indicating that there are too many output arguments when neither call to plot is expecting any...
Please copy and paste the full error message so that we can see which line is generating the error.
*Error using resist1
Too many output arguments.
Error in resist_function_attempt (line 6)
[r1] = resist1(T)*
This is the error i get.
one of the of the functions looks like this:
function resist1(T)
dT=T-20;
p=0.0178;
a=0.0039;
r1=p*(1+(a*dT));
r1
The other function is very similar, the equation in it is just a bit more complex but still gives an output the same size as r1
function r1 = resist1(T)
dT=T-20;
p=0.0178;
a=0.0039;
r1=p*(1+(a*dT));
Walter, make it an Answer, not a comment.

Réponses (1)

Are you certain that you've defined each of MyFunction1 and MyFunction2 to return at least one output argument? For example, you would receive the error you quoted if you attempted to call the clc function (which is defined to have 0 output arguments) with an output argument.
Q = clc % WILL throw an error

Cette question est clôturée.

Question posée :

le 10 Juil 2017

Clôturé :

le 20 Août 2021

Community Treasure Hunt

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

Start Hunting!

Translated by