fprintf help wont show full statement

5 visualizaciones (últimos 30 días)
Ben Newton
Ben Newton el 31 de Oct. de 2019
Comentada: Rena Berman el 12 de Dic. de 2019
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 comentarios
Stephen23
Stephen23 el 8 de Nov. de 2019
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 el 12 de Dic. de 2019
(Answers Dev) Restored edit

Iniciar sesión para comentar.

Respuestas (1)

Rik
Rik el 31 de Oct. de 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 comentarios
Steven Lord
Steven Lord el 31 de Oct. de 2019
Good catch, I missed that mark after the word rootproof.
Rik
Rik el 31 de Oct. de 2019
I just formatted the question, so now it is more obvious ;)

Iniciar sesión para comentar.

Categorías

Más información sobre Scripts en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by