repeat function and calculation
조회 수: 11 (최근 30일)
이전 댓글 표시
here is my code
x=('input x')
y=x^+2
how do I ask once I get my output if I want the calculation to be repeated again
댓글 수: 2
답변 (1개)
Ameer Hamza
2020년 3월 8일
This is a general structure of what you are trying to do
condition = true;
while condition
x = input('Enter a number: ');
y = x.^2;
disp(y);
condition = input("Do you want to continue? (yes/no)\n", 's') == "yes";
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!