hello everyone
Is there a way to store the answers from a while loop in a vector?? Id like to know how to do that. I know its possible with for loops
thank you

 채택된 답변

Star Strider
Star Strider 2014년 9월 14일

0 개 추천

It is. You simply have to create a counter:
k1 = 1;
x = 0;
while x < 25
x = k1^2; % Calculate ‘x’
y(k1) = x; % Store the value of ‘x’ in vector ‘y’
k1 = k1 + 1; % Increment counter
end

댓글 수: 2

oselu
oselu 2014년 9월 14일
Thank you very much:)
Star Strider
Star Strider 2014년 9월 14일
My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2014년 9월 14일

댓글:

2014년 9월 14일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by