MATLAB Answers

0

fprintf help wont show full statement

Asked by Ben Newton on 31 Oct 2019
Latest activity Commented on by Stephen Cobeldick on 8 Nov 2019 at 8:22
This question was flagged by Star Strider
this question has been removed and should be deleted

  4 Comments

Show 1 older comment
Rik
on 7 Nov 2019 at 23:39
It is extremely rude to edit away your question. This is a public forum where you can get free help from strangers on the internet. The least you can do is leave the question as it was, so people with a similar question can find an answer here.
Ben Newton on 8 Nov 2019 at 0:16
i understand and apologise from this point on i will no longer post questions on here unless i intend to keep them up
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?

Sign in to comment.

Tags

1 Answer

Answer by Rik
on 31 Oct 2019

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 Comments

Good catch, I missed that mark after the word rootproof.
Rik
on 31 Oct 2019
I just formatted the question, so now it is more obvious ;)

Sign in to comment.