MATLAB Answers

fprintf help wont show full statement

1 ビュー (過去 30 日間)
Ben Newton
Ben Newton 2019 年 10 月 31 日
Commented: Rena Berman 2019 年 12 月 12 日
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 件のコメント

表示 2 件の古いコメント
Ben Newton
Ben Newton 2019 年 11 月 8 日
i understand and apologise from this point on i will no longer post questions on here unless i intend to keep them up
Stephen Cobeldick
Stephen Cobeldick 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?
Rena Berman
Rena Berman 2019 年 12 月 12 日
(Answers Dev) Restored edit

サインイン to comment.

件の回答 (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 ;)

サインイン to comment.

サインイン してこの質問に回答します。

タグ


Translated by