필터 지우기
필터 지우기

Printing out a variable in while loop?

조회 수: 1 (최근 30일)
Nick Haufler
Nick Haufler 2015년 10월 12일
댓글: Nick Haufler 2015년 10월 12일
In my document, Im pretty sure my code is right, I just dont get why my estimated and actual cube root values come out the same. I dont think theyre supposed to be that way, and I have no idea what variable to print out for the actual cube root fprintf statement. Would i need an equation for an actual cube root, although the directions dont say anything about that. Right now, I am just greatly confused, the help i have received so far isnt clicking for me.

채택된 답변

Geoff Hayes
Geoff Hayes 2015년 10월 12일
Nick - your answers come out the same since you are writing out the same variable for each print statement:
fprintf('The actual cube root is %0.3f\n', Estimate)
fprintf('The estimate of the cube root is %0.3f\n', Estimate)
The actual cube root of the input number would be
fprintf('The actual cube root is %0.3f\n', x^(1/3));
where x is the number that you are trying to compute the cube root of. For example,
x = input('Please enter a number:');
will allow the user to enter a number that he or she wishes to find the cube root of. Note that in your code you do
CubeRoot=input('Please enter a number:')
The above line is misleading since the number entered by the user is not the cube root but is the number that they wish to find the cube root of.
  댓글 수: 1
Nick Haufler
Nick Haufler 2015년 10월 12일
Geoff- Thank You VERY MUCH! I finally understand it. I do see what you were saying about my input statements. I really appreciate your help. Thanks again!

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

추가 답변 (1개)

Steven Lord
Steven Lord 2015년 10월 12일
As John stated two days ago, DON'T KEEP POSTING THE SAME QUESTION REPEATEDLY!
Walter TOLD you what was wrong in another post from two days ago. Reread what he wrote.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by