When you print MATLAB code or the published form of the code, you may find the code or the comments getting cut off. The solution to these problems is given at several places in MATLAB blogs and documentation. In this blog, I have summarized what to do as the issues of code getting cut off falls into three categories
- Break long MATLAB statements by using the … command. See this link for examples and the nature of the command
http://www.mathworks.com/help/matlab/matlab_prog/continue-long-statements-on-multiple-lines.html - Break long comments simply by putting them on separate lines
For example
% My name is Autar, my age is 20, my major is Mechanical Engg
can be written as
% My name is Autar
% my age is 20
% my major is Mechanical Engg - If you want to print a long string without running off the page along its width, break the string and then concatenate the resulting strings vertically. http://www.mathworks.com/help/matlab/ref/strvcat.html Then use the disp statement to print the string to the command window or in published format.
___________________________________________
This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://nm.mathforcollege.com, the textbook on Numerical Methods with Applications available from the lulu storefront, the textbook on Introduction to Programming Concepts Using MATLAB, and the YouTube video lectures available at http://nm.mathforcollege.com/videos. Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.