Using fprintf to display multiple strings

30 views (last 30 days)
Ananyapam De
Ananyapam De on 27 Jul 2020
Edited: Stephen23 on 27 Jul 2020
This piece of code
fprintf('%s + %s',char(955))
should give me λ+λ but it only gives λ +
How should I solve this?

Answers (2)

KSSV
KSSV on 27 Jul 2020
fprintf('%s + %s',char(955),char(955))

Stephen23
Stephen23 on 27 Jul 2020
Edited: Stephen23 on 27 Jul 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:

Categories

Find more on Software Development Tools in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!