Using fprintf to display multiple strings

22 visualizaciones (últimos 30 días)
Ananyapam De
Ananyapam De el 27 de Jul. de 2020
Editada: Stephen23 el 27 de Jul. de 2020
This piece of code
fprintf('%s + %s',char(955))
should give me λ+λ but it only gives λ +
How should I solve this?

Respuestas (2)

KSSV
KSSV el 27 de Jul. de 2020
fprintf('%s + %s',char(955),char(955))

Stephen23
Stephen23 el 27 de Jul. de 2020
Editada: Stephen23 el 27 de Jul. de 2020
Very simply add an identifier to the format specifier:
fprintf('%1$s + %1$s',char(955))
% ^^ ^^ input identifiers
The identifier tells MATLAB which input to use. See:

Categorías

Más información sobre Software Development Tools 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