This question is closed. Reopen it to edit or answer.
I need help with defining while loops?
1 view (last 30 days)
Show older comments
Closed: MATLAB Answer Bot on 20 Aug 2021
Hello. I want write a code which can performe to generate matrix automaticlly. In the last while loop in my code I want to define that the 3:rd column and 2:nd row is =5 and the 2:nd column and 2:nd row is = 7 and the rest of the row tow is = 0 when we do not have any more number. Plz help me to solve this issue.
stra= num2str(a); %#########convert (a) to string format
strb=num2str(b); %#########convert (b) to string format
% M=zeros(sizea, sizeb);
if sizea > sizeb
ncols = sizea
M= zeros (nrows, ncols)
while sizea >= 1
M(1, sizea) = str2num(stra(1, sizea)) %(stra(stra(1), size(a)))
M=zeros (nrows, ncols)
while sizeb >= 1
M(2, sizeb) = str2num(strb(1,sizeb))
Eng. Fredius Magige on 13 Nov 2015
Your increment is missing which support to allow application of while. Both if and else are inner within wile loop as well as to end by end.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!