How to do while loop on arrays?
Mostrar comentarios más antiguos
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 comentarios
David Fletcher
el 4 de Abr. de 2021
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
el 5 de Abr. de 2021
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!