fprintf help wont show full statement

2 次查看(过去 30 天)
fprintf("afunc*bfunc gives us %d therefore is a root between 0 and 5 \n', rootproof")
%gives the output
afunc*bfunc gives us >>
where have i gone wrong?
  5 个评论
Stephen23
Stephen23 2019-11-8
Original question:
fprintf("afunc*bfunc gives us %d therefore is a root between 0 and 5 \n', rootproof")
%gives the output
afunc*bfunc gives us >>
where have i gone wrong?

请先登录,再进行评论。

回答(1 个)

Rik
Rik 2019-10-31
Simply pasting what you posted into my copy of Matlab gives a hint about the cause:
I get a warning from m-lint (the orange squiggle) that states that "The format might not agree with the argument count".
The reason is that you made the entire input a string, instead of only the format specifier. Do not mix single and double quotes. Either of the versions below will work.
rootproof=3;
fprintf("afunc*bfunc gives us %d therefore is a root between 0 and 5 \n", rootproof)
fprintf('afunc*bfunc gives us %d therefore is a root between 0 and 5 \n', rootproof)
  2 个评论
Steven Lord
Steven Lord 2019-10-31
Good catch, I missed that mark after the word rootproof.
Rik
Rik 2019-10-31
I just formatted the question, so now it is more obvious ;)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by