MATLAB: How to write this for loop into while loop for loopwhile loop Guys, this seems very simple and trivial, but I'm having a great amount of difficult with this I have this for loop below, how can I write it in the while form? for k=1:3:9 x=k^2end Best Answer Something like this might do itk = 1;while k <= 9 x = k^2 k = k+3;end Related SolutionsMATLAB: Converting for loop to while loop for i =1:5 j=1; k=1; while j<=5-i fprintf(' '); j = j+1; end while k<=i fprintf('*'); k = k+1; end fprintf('\n')end MATLAB: While or for loop Use while loopinstead of using if else and continue break in while(true), add condition in while loopPrint after the while loop endsPS: you need a break condition for a while(true) type loop otherwise it will continue runing forever Related QuestionHow to find cube root using while loopProblem in while loop
Best Answer