MATLAB: While loop for sum while loop Hi, I need to read in an integer N from the keyboard and then use while loop to compute the value of the expression. The expression is ((n+1)/sqrt(n)+n^3) Best Answer n = 1;while true do something n = n + 1; if n > N; break; endendorn = 0;while true n = n + 1; if n > N; break; end do somethingendorn = 1;while true do something if n >= N; break; end n = n + 1;endorn = 1;while n <= N do something n = n + 1;endorn = 0;while true if n > N; break; end n = n + 1; do somethingend Related SolutionsMATLAB: Sum I am a little confused, do you mean like this:Y = reshape(1:18,6,3) % A manageable dimension.Y_1 = sum(Y,2)So in your case it would beY_1 = sum(Y,2).';..Or do you mean, more like this:Y = 1:18Y_1 = sum(reshape(Y,3,6))So in your case it would beY_1 = sum(reshape(Y,320,467)) MATLAB: For and while loops function F = getFacWhile(n) F=1; while n>1 F=F*n; n=n-1; endendfunction F = getFacWhile(n) F=1; for i=1:n F=F*i; endend Related QuestionSum functionDisplay while loop output as an arrayCan anybody help on this FOR loopsHow to write sum
Best Answer