If none exists, just as an axes will be created (equivalent to an explicit The figure call here is optional because a figure will be created Setp function with a line or lines as argumentĭef f ( t ): return np. To get a list of settable line properties, call the Here are the available Line2D properties.Ī Path instance and a Transform instance, a PatchĪ instance setp ( lines, color = 'r', linewidth = 2.0 ) # or MATLAB style string value pairs plt. plot ( x1, y1, x2, y2 ) # use keyword arguments plt.
![matlab plot function matlab plot function](https://www.mathworks.com/help/examples/graphics/win64/SpecifyPlottingIntervalAndPlotPiecewiseFunctionsExample_01.png)
#Matlab plot function code#
After that, use the entries on the Cell Menu or the icons on the toolbar to execute the code in the cells provided in the file. The file complex.m is designed to be run in "cell mode." Open the file complex.m in the Matlab editor, then enable cell mode from the Cell Menu.
#Matlab plot function download#
Download the file to a directory or folder on your system. You can download the Matlab file at the following link. Matlab FilesĪlthough the following file features advanced use of Matlab, we include it here for those interested in discovering how we generated the images for this activity. You can try to eliminate this behavior by increasing the number of points in the mesh, but in upcoming activities we'll demonstrate how a change of coordinates is a better solution. Replacing complex entries in z witn NaN's.Īs we saw in Example 1, we have some erratic behavior on the boundary (`x^2+y^2=4`) of the hemisphere. The following command should work on all systems. Users must have complained, because later versions of Matlab 7 have returned to the days of Matlab 6 and the mesh command will not work if entries have data that is complex.īy taking the real part of `z`, complex numbers are avoided. Then, in the early development of Matlab 7, an adjustment was made to Matlab's mesh command to allow it to work with complex data specifically, an adjustment in the code allowed it to deal with complex data in the same way as the the plot command dealt with complex data: it plotted the real part of any complex data entry. During the development stages of version 6, Matlab's mesh command would fail if it detected complex numbers in the data. How Matlab's mesh command will perform depends on your version of Matlab. If you scroll through the entries in z you'll find the complex entries. You can view the entries of z, much as we did the entries in y in Example 1, by typing z at the command prompt, followed by the Enter key. The false response (0 indicates 'false' in Matlab) is an indication that not all of the entries of z are real i.e., some entries are complex.
![matlab plot function matlab plot function](https://www.mathworks.com/help/examples/graphics/win64/SpecifyLinePropertiesAndDisplayMarkersExample_01.png)
The beauty of this approach is the fact that Matlab's plot command ignores NaN's when plotting. Thus, we want to find the entries in the vector y whose real part does not equal itself.ġ.1055 1.0082 0.8964 0.7636 0.5961 0.3468 NaN If a number is real, then its real part equals itself. First, use Matlab's find command to find all entries that are not real. We can replace each complex entry in the vector y with a NaN. Hence the horizontal segments `y=0` at each end of the plot in Figure 1. Matlab's plot command ignores the imaginary part of any complex data and plots only the real part, which in the case of this example, is always zero. This output explains the strange horizontal segments at each end of the plot in Figure 1. Note especially that the real part of each of these complex numbers is zero. Note that there are complex entries at the beginning and end of the vector y.