Ability to break long fprintf statements

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.

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

Author: Autar Kaw

Autar Kaw (http://autarkaw.com) is a Professor of Mechanical Engineering at the University of South Florida. He has been at USF since 1987, the same year in which he received his Ph. D. in Engineering Mechanics from Clemson University. He is a recipient of the 2012 U.S. Professor of the Year Award. With major funding from NSF, he is the principal and managing contributor in developing the multiple award-winning online open courseware for an undergraduate course in Numerical Methods. The OpenCourseWare (nm.MathForCollege.com) annually receives 1,000,000+ page views, 1,000,000+ views of the YouTube audiovisual lectures, and 150,000+ page views at the NumericalMethodsGuy blog. His current research interests include engineering education research methods, adaptive learning, open courseware, massive open online courses, flipped classrooms, and learning strategies. He has written four textbooks and 80 refereed technical papers, and his opinion editorials have appeared in the St. Petersburg Times and Tampa Tribune.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s