How to do while loop on arrays?
古いコメントを表示
Hi there, I'm new to matlab, I'm having problem doing while loop on arrays. Apparently the logic for the while loop is wrong, it should go row by row until E equals to zero...can someone help please? It's kind of urgent. Thanks!
A=5000;
B=4000;
C=3000;
D=2000;
E=1000;
i=1;% row 1
i=[A B C D E]
%---------do this first----------------
%while i(1,5)>0 %the logic here is that value E should be more than zero to proceed
i(1,1)=i(1,5); %beginning balance row 2
i(1,2)=i(1,1)*1.5/12 %interest row 2
i(1,3)=i(1,2)-i(1,3); %principal row 2
i(1,4)=i(1,1)-i(1,4); %ending balance row 2
i=i+1;
i=[i;i(1,1),i(1,2),i(1,3),i(1,4),i(1,5)];
%------formula-------------------------
%‹end
2 件のコメント
David Fletcher
2021 年 4 月 4 日
i=1;% row 1
i=[A B C D E]
I'm not really sure I have much of a clue what you are doing, but do you really want to declare i=1 and then immediately overwrite it with a vector.
Phoebe
2021 年 4 月 5 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!