Plot () function: Just specify the Parameter
Plot (x, y) to draw the image, X is the X coordinate, Y is the Y coordinate
Requirement: X and Y are vectors of the same length?
Special usage:
A; X is the vector, Y is the matrix, and the length of the period one-dimensional and X is the same
1 x=0:0.1:8; 2 3 y=sin(x); 4 5 plot(x,y) 6 7 >> x=0:0.1:8; 8 9 >> y1=sin(x);10 11 >> y2=cos(x);12 13 >> z=[y1;y2];14 15 >> plot(x,z);
B: Use parameters to express different colors and States
1 x=0:0.1:2*pi;2 3 y=sin(x);4 5 plot(x,y,‘b‘);
Parameters can be used together
B blue (blue). Point (point)-solid (solid line)
G Green (green) O circle (circle): dotted (DOT line)
R red (red) x-mark (Cross)-. dashdot (DOT draw line)
C cyan (dark green) + plus (plus sign) -- dashed (dotted line)
M magenta (purple) * Star (asterisk) (none) No line
Y yellow (yellow) s square (square)
K black (black) d Diamond (diamond)
C: graphic Annotation
Title ('text', 'property1', propertyvalue1, 'property2', propertyvalue2 ,...)
The image name is displayed on the top. You can use
Title ('parabolic ', 'color', 'R', 'fontsize', 20 );
Set question font size and color
Xlabel ('text'): X axis Annotation
Yalvel ('text'): Y axis Annotation
Text (X, Y, 'string') adds the string in quotes to the location specified by the point (x, y) x and y must be numbers of class double. Legend
Legend () Create icon
1 x = 0: 0. * PI; 2 3 Y = sin (x); 4 5 plot (x, y); 6 7 xlabel ('abscissa '); 8 9 ylabel ('ordinate '); 10 11 Title ('sin function image', 'color', 'R', 'fontsize', 20); % Title 12 13 text (4,0, '\ leftarrow y = sin (x)'); % write something in the position on the graph 14 15 legend ('sin'); 16 17
D: Coordinate Control
Xlim ([xmin xmax])
Ylim ([xmin xmax]) % controls the coordinate range displayed in the chart
There are other similar functions: Adjusting the coordinate axis shape and so on.
E: graphic persistence
1 x = 0: 0. 1: 4 * PI; 2 y = sin (x); 3 y2 = cos (x); 4 hold on 5 plot (x, Y2); 6 plot (x, y ); % draw two images. If there is no hold on above, a y will be generated. Hold on means holding different images in a coordinate axis 7 xlabel ('abscissa '); 8 ylabel ('ordinate '); 9 Title ('sin function image', 'color', 'R', 'fontsize', 20); % Title 10 text, '\ leftarrow y = sin (x)'); % write something in the position on the graph 11 legend ('sin ');
F: Split display of images
The subplot (MNP) function is used to plan multiple functions created together.
1 x = 1:0. 1: 6; 2 y = x; 3 Y1 = sin (x); 4 y2 = cos (x); 5 Y3 = Log (x); 6 subplot (221) % is divided into 2*2 squares, and the graph is placed in the first 7 plot (x, y); 8 subplot (222) % is divided into 2*2 squares, place the graph in the second 9 plot (x, Y1); 10 subplot (223) % Into A 2*2 square, and place the graph in the third 11 plot (x, Y2 ); 12 subplot (224) % is divided into 2*2 squares, and the graph is placed in the fourth 13 plot (x, Y3 );