Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Undefined function. Can anyone plz help me!

1 回表示 (過去 30 日間)
Claude Liao
Claude Liao 2015 年 3 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I followed the textbook and type the exact code. But still it doesn't work. I can not find anything wrong from it, just can not understand why the solution function could not be generated? Can anyone plz help me! Thanks!
num=[100];
den=[0.36 1.86 2.5 1];
K=[2.0 2.2 2.4 2.6 2.8 3.0];
a=[0.5 0.7 0.9 1.1 1.3 1.5];
t=0:0.01:5;
g=tf(num,den);
k=0;
for i=1:6;
for j=1:6;
gc=tf(K(i)*[1 2*a(j) a(j)^2],[1 0]);
G=gc*g/(1+gc*g);
y=step(G,t);
m=max(y);
if m<1.10
k=k+1;
solution(k,:)=[K(i) a(j) m];
end
end
end
The outcome should be that when I type solution in the command window and a table of figures will be generated, however what I got is just the remind that Undefined function or variable 'solution'.

回答 (1 件)

Image Analyst
Image Analyst 2015 年 3 月 2 日
This line:
solution(k,:)=[K(i) a(j) m];
never gets executed. Use the debugger to figure out why. This is something you will absolutely have to learn to do if you want to write programs in MATLAB. All of us do it, you need to too.
  2 件のコメント
Claude Liao
Claude Liao 2015 年 3 月 2 日
I have already found the problem, when I delete the if statement, the solution function will be generated, however when I add the if statement, it goes wrong. Could please tell me how can I add the if statement properly?
Image Analyst
Image Analyst 2015 年 3 月 2 日
I have no idea why you put that if statement in there. This is what happens when you don't put comments in your code - other people can't maintain your code for you. Why is the if statement in there in the first place? If you don't want it, take it out. I have no idea if it's supposed to be there or not.

製品

Community Treasure Hunt

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

Start Hunting!

Translated by