Using an apostrophe with fprintf

24 ビュー (過去 30 日間)
Megan Lavery
Megan Lavery 2015 年 2 月 16 日
回答済み: Roger Stafford 2015 年 2 月 16 日
How do I include an apostrophe within my text while using the fprintf command? For example, fprintf('Avogadro's constant is 6.022e+23 molecules/mole.\n') will not work because the apostrophe in "Avogadro's" ends the text segment.

採用された回答

Image Analyst
Image Analyst 2015 年 2 月 16 日
Use a double single quote character to print a single quote character:
fprintf('Avogadro''s constant is 6.022e+23 molecules/mole.\n')

その他の回答 (1 件)

Roger Stafford
Roger Stafford 2015 年 2 月 16 日
Use double apostrophe just as you would in any matlab string:
fprintf('Avogadro''s constant is 6.022e+23 molecules/mole.\n')

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by