Using fprintf to display multiple strings

20 ビュー (過去 30 日間)
Ananyapam De
Ananyapam De 2020 年 7 月 27 日
編集済み: Stephen23 2020 年 7 月 27 日
This piece of code
fprintf('%s + %s',char(955))
should give me λ+λ but it only gives λ +
How should I solve this?

回答 (2 件)

KSSV
KSSV 2020 年 7 月 27 日
fprintf('%s + %s',char(955),char(955))

Stephen23
Stephen23 2020 年 7 月 27 日
編集済み: Stephen23 2020 年 7 月 27 日
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:

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by