MATLAB is technical computing software used by scientists and engineers for processing and analysing data stored in arrays and matrices. Plotting the data assists in visualising the data after the appropriate calculations are performed. Frequently, it is necessary to change the plot properties and appearance to support the data. The axes of the plot show the scale of the graph using tick marks and labels, which are used to match the plot line with its value. You can change the axes on a MATLAB plot, including the limits of each axis, the location and frequency of the tick marks, and the font labels' colour and weight.
- Skill level:
- Moderately Easy
Other People Are Reading
Clear all active variables within the workspace by entering "clear all" in the MATLAB Command window.
Create sample data to plot. Input "x=1:1:50;" and "y=rand(1,50);" in the Command window. This creates a 50-element array for "x," starting at 1 and ending at 50, and a 50-element array of random numbers for "y."
Plot the sample data created in Step 3 by inputting "plot(x,y)" in the Command window. A new window appears labelled Figure 1, showing the sample data using a solid line.
Change the x-limits and y-limits of the plot by modifying the command used in Step 3 by entering "plot(x,y); xlim([1 55])", which changes the limits of the x-axis from 50 to 55. Use the command "ylim" to change the y-axis limits.
Change additional axis properties by clicking on "Show Plot Tools and Dock Figure" from the Figure menu. Click anywhere on the plot. Under the "X-Axis" tab, add in the axes labels and change the axes limits. Click on the "Ticks" button to change the axes scales and tick mark locations. Change the y-axis properties by clicking on the "Y-Axis" tab. Change the font of the axes labels by clicking on the "Font" tab.
Tips and warnings
- All properties mentioned in Step 5 can be incorporated into the Command window, reducing the need to detail each individual plot. Refer to the appropriate MATLAB documentation for additional commands.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for