How to use Print MATLAB

How to use Print MATLAB
In the tutorial How to use Print MATLAB, I will tell you about the use of this command in MATLAB while explaining a lot of examples and by displaying their results. The examples include the printing of the statement on the command window in MATLAB as well as to display the graphs and to save its image.- Here, I am going to print some statement (the name of our website) on the command window using this particular command in m.file.
- The use of the command fprintf is shown below.
clc % clears the command window
fprintf('www.TheEngineeringProjects.com\n')% prints the desired statement
- Editor also displays that command in the figure shown below.
- You can observe the result of this statement on the command window in MATLAB.
- The result displayed on the command window is shown in the figure below.
- So, that was about how to print the statement on the command window.
- Now, I am going to print the result of some mathematical operations applied on some variables, on command window using the same command.
- I have assigned different values to the two variables a and
- I have calculated their sum and displayed on the command window.
- The commands written on the editor are shown in the figure below.
- The result of the above commands displayed on the command window is shown in the figure below.
- So, that was the description of how to print the results mathematical operations applied on some variables on command window.
- Now, I am going to perform some operations on matrix.
- The source code written in editor of the MATLAB is shown below.
- I have initialized a matrix named as
- I have then displayed that matrix on the command window.
- At the end, I have printed all the values of that matrix on the command window.
- The result of all the above commands displayed on the command window is shown in the figure below.
- First row in the above figure displays the matrix.
- And the second row prints each value of the matrix in next ling using \n.
Graphics Format File
- You need to specify file name and format switch to save your figure as graphics.
- The supported output formats for exporting from MATLAB and switch settings are shown in the table given below.
Print Paper Copy of Figure
In this method a new bar chart will be created and printed to your system default computer. If you do not specify the figure to be printed, then print will use the current figure.- The source code written on the editor is shown below.
clc bar(1:10); print
- The editor window with the code is also shown in the figure below.
- The figure generated from the above code is shown below.
- That was the detailed discussion about using print command as a debugging tool in MATLAB.
×
![]()





































































