Using fprintf to display multiple strings

This piece of code
fprintf('%s + %s',char(955))
should give me λ+λ but it only gives λ +
How should I solve this?

Antworten (2)

KSSV
KSSV am 27 Jul. 2020

0 Stimmen

fprintf('%s + %s',char(955),char(955))
Stephen23
Stephen23 am 27 Jul. 2020
Bearbeitet: Stephen23 am 27 Jul. 2020

0 Stimmen

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:

Kategorien

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

Tags

Gefragt:

am 27 Jul. 2020

Bearbeitet:

am 27 Jul. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by