Hello. MATLAB beginner here. I'm trying to convert a for loop to a while loop to finish up a final homework problem and it's supposed to get the same results, but it's not. I'm only getting the random numbers from the beginning equation. I believe the issue shouldn't be this hard to find, but I can't pinpoint what's wrong.
x=6*rand(1,10)+2for i=1:10 if i<5 x(i)=-1; elseif i>=5 && i<8 x(i)=1; else x(i)=3; endendx
Best Answer