Too many output arguments.
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Paul Rogers
am 16 Dez. 2019
Bearbeitet: per isakson
am 18 Dez. 2019
I've found this code that may help me a lot.
I cannot run, it keeps saying:
Error using type
Too many output arguments.
my version is 2014b
the code is
function [t,y]=valori(type)
a=340;
S=0.25;
x10=0.85;
U=144;
if (type == 1)
Ac=0.0034;
Vp=0.32;
Lc=0.3;
H=3.2613e4;
W=0.3689;
else
if (type == 2)
Ac=0.0033;
Vp=0.025;
Lc=1.22;
H=0.09e5;
W=0.1;
else
Ac=0.0090;
Vp=0.001;
Lc=2.8;
H=1.55e4;
W=0.1587;
end
end
[t,y]=greitzer2(a,Ac,Vp,Lc,U,H,W,x10,S);
end
function [t,y]=greitzer2(a,Ac,Vp,Lc,U,H,W,x10,S)
wh=a*sqrt(Ac/(Vp*Lc));
B=U/(2*wh*Lc);
k=x10-S*(x10-(1/3)*(x10.^3));
[t,y]=ode45(@(t,y)greitzer10(H,W,B,U,Ac,y,S,k),[0 100],[0,0]);
subplot(2,2,1)
plot(t,y(:,1))
xlabel('t')
ylabel('\phi_c')
subplot(2,2,2)
plot(y(:,1),y(:,2))
xlabel('\phi_c')
ylabel('\psi')
subplot(2,2,3)
plot(t,y(:,2))
xlabel('t')
ylabel('\psi')
end
function dydt = greitzer10(H,W,B,U,Ac,y,S,k)
dydt = [ ((3*H*Ac*B)/(W*U))*((y(1)-(1/3)*((y(1).^3)))-y(2)); ((W*U)/(3*H*Ac*B))*(y(1)-(S*y(2)+k)) ];
end
this might be a missing part:
function y=carcomp(C0,H,x,W)
y=C0+H*(1+(3/2)*((x/W)-1)-(1/2)*(((x/W)-1).^3));
0 Kommentare
Akzeptierte Antwort
per isakson
am 17 Dez. 2019
Bearbeitet: per isakson
am 17 Dez. 2019
I fail to reproduce the error you report
>> [t,y] = valori( 2 );
>> [t,y] = valori( 1 );
>> [t,y] = valori( 3 );
no error, no warning and produces a figure with three diagrams.
However
>> [t,y] = valori( type );
Error using type
Too many output arguments.
>>
"type" is the name of a function that doesn't return any output. Try
>> type=1; [t,y] = valori( type );
That works, but now you'll get unexpexted results if you try to use the function, type
Conclusion: Avoid to use function names as names of variables.
4 Kommentare
per isakson
am 18 Dez. 2019
Bearbeitet: per isakson
am 18 Dez. 2019
"This statement is not inside any function." Why did you put it at the end of the file?
Here is a screen clip of the end of your file valori.m
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/254896/image.png)
Comments
- Upper left corner. With an indention of 4, I find it easier to see the scope of the functions.
- Upper right corner. The red box shows that the Code Analyzer has spotted a syntax error. Try to understand and fix that problem before running the code. See Check Code with the Code Analyzer
- The arrow points at the the end of the function valori.
Move the lines 61-66 to the end of the function valori.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spline Postprocessing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!