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.

 Akzeptierte Antwort

Image Analyst
Image Analyst am 16 Feb. 2015

4 Stimmen

Use a double single quote character to print a single quote character:
fprintf('Avogadro''s constant is 6.022e+23 molecules/mole.\n')

Weitere Antworten (1)

Roger Stafford
Roger Stafford am 16 Feb. 2015

0 Stimmen

Use double apostrophe just as you would in any matlab string:
fprintf('Avogadro''s constant is 6.022e+23 molecules/mole.\n')

Kategorien

Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by