Ability to break long fprintf statements

Problem:
A student sent me an email – ” I can’t figure out how to continue my text on another line in the editor while using the fprintf command in MATLAB.  It seems like this should be something simple, but I can’t figure it out.  The closest thing I have tried is:
fprintf(‘filler filler filler’, …
‘filler filler’)

When I run this script, this only displays the content within the first set of quotes though.

Solution:
Assign the long strings to variables, and then use the fprintf statements

abc=’My name is’
def=’ Slim Shady, also known as Marshall Mathers’
fprintf([abc def])

or you could do the following, especially if you have other non-string variables to print

abc=’My name is’
def=’ Slim Shady, also known as Marshall Mathers’
fprintf(‘%s %s’,abc,def)

_____________________

This post is brought to you by

Leave a Reply