fprintf help wont show full statement

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 Kommentare

Steven Lord
Steven Lord am 31 Okt. 2019
Show us the size, class, and contents (or at least the first couple of elements, if it has many elements) of the variable rootproof.
Rik
Rik am 7 Nov. 2019
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
Ben Newton am 8 Nov. 2019
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?
Rena Berman
Rena Berman am 12 Dez. 2019
(Answers Dev) Restored edit

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Rik
Rik am 31 Okt. 2019

2 Stimmen

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 Kommentare

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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Entering Commands finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 31 Okt. 2019

Kommentiert:

am 12 Dez. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by