for t_temp=0:1/250/1000:3/250
Te_temp = subs(Te,t,t_temp);
Te_temp = double(Te_temp);
Te_array = [Te_temp Te_array];
precent = ((t_temp)/(3/250))*100;
% if percent>10*cnt
% cnt=cnt+1;
fprintf("%f%%\n",percent);
% fprintf("%f%%\n",t_temp/(3/250)*100);
% end
end
Hi, I have a question about calculation bug in MATLAB.
I want to check progress of the loop, so I calculate the percent separately as "percent" variable.
But the result is 0.00000 .
If I print the value which is calculated directly such as "fprintf("%f%%\n", t_temp/(3/250)*100)";,
It works!!! I don't know the difference these two statement.
Are there any other who have this problem?

 채택된 답변

madhan ravi
madhan ravi 2018년 11월 16일
편집: madhan ravi 2018년 11월 16일

0 개 추천

use
format longg % nothing wrong in your calculation it's scientific notation
at the very beginning of your code
see format and use appropriate notation you want

댓글 수: 2

jae hak kim
jae hak kim 2019년 1월 8일
Thank you for your reply:)
Stephen23
Stephen23 2019년 1월 8일
@madhan ravi: rather than putting a link to a google search for format, it would be better to just put a link to the format help page itself.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

제품

릴리스

R2017a

질문:

2018년 11월 16일

댓글:

2019년 1월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by