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에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!