how to create a loop function
古いコメントを表示
first of all I am new in matlab. And I have a code like this:
k=1.4; z=200
for i=330:-1:6;
for j=330:-1:6;
x(i)=i;
y(j)=(x(i-1)/x(i))^((k-1)/k)*z;
%now I want to repeat this such as
y(j-1)=(x(i-2)/x(i-1))^((k-1)/k)*y(j);
end
end
can anyone tell me how to correct this?? thx a lot
[EDITED, Jan, Please apply code formatting - Thanks]
1 件のコメント
David Young
2015 年 3 月 6 日
Please use the "{} Code" button to format your code. It's then much easier to read.
Please also can you say what is wrong - an error message, or an incorrect result?
回答 (2 件)
Jan
2015 年 3 月 6 日
0 投票
It is impossible to correct a piece of code, if this code is all available information. The wanted result cannot be guessed.
Currently it looks strange, that the elements of y(j-1) are overwritten in the next iteration.
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!