This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
plots [2015/05/06 11:56] petersen |
— (current) | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== Plots ===== | ||
| - | |||
| - | Plots allow the user to graphically compare two variables together. The basic syntax is | ||
| - | |||
| - | plot(X , Y, S). | ||
| - | |||
| - | X is an array consisting of x coordinates and Y is an array consisting of Y coordinates. S allows the user to select various line types. If you type in “help plot” in the command window you can see this section that explains the purpose of S. | ||
| - | |||
| - | {{ :plots.png?500 |}} | ||
| - | From Matlab | ||
| - | |||
| - | You can also plot multiple Xs, Ys, and Ss using the following syntax. | ||
| - | |||
| - | plot(X1, Y2, S1, X2, Y2, S2, Xn, Yn, Sn); | ||
| - | |||
| - | When you create a plot Matlab will display it on a figure | ||
| - | |||
| - | |||
| - | |||
| - | The following are useful commands associated with plots | ||
| - | |||
| - | To adjust the x and y axis limits | ||
| - | xlim( [Xmin Xmax]) | ||
| - | ylim( [Ymin Ymax]) | ||
| - | |||
| - | To write a header | ||
| - | text(‘insert text here’) | ||
| - | |||
| - | Create labels on the x and y axis | ||
| - | xlabel(‘insert label here’) | ||
| - | ylabel(‘insert label here’) | ||
| - | |||
| - | |||
| - | place multiple graphs on the same figure | ||
| - | hold on | ||
| - | |||
| - | create a legend | ||
| - | legend(string1, string2, string, ‘location’, string_of_location) | ||
| - | ‘location’ is to indicate that you will tell matlab where to put the legend | ||
| - | |||
| - | Specify which figure to use. | ||
| - | figure(x); x = 1, 2, 3 ……. | ||
| - | |||
| - | |||