MATLAB: Using an apostrophe with fprintf

fprintf

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.

Best Answer

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