Too many output arguments.
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
per isakson
2019-12-17
编辑:per isakson
2019-12-17
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 个评论
per isakson
2019-12-18
编辑:per isakson
2019-12-18
"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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spline Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!