Chapter III selection structure of Matlab
General steps for 3.1 program writing
3.2 Relational operators
1) 0 means false, not 0 is true;
2) ~=: Not equal;
3) sin (pi) ~= 0: 1, compare a,b Two number equality method:ABS (a) < 1.0e-14
3.3 Logical Operation
1) first with & after or |
3.4 logic function and short circuit operation
1) Short circuit operation:&&,| | ; non-short-circuit operation: & , |
2) Ischar (x),isempty (x),isinf (x),isnan (x ) : Is not a number,isnumeric (x): Whether it is a number
3) 1/0 = INF is number;0/0 = NaN is not a number
3.5 If statement
1) Statement structure: "If" begins, "End" ends
If Exp_1
Block_1
ElseIf exp_2
Block_2
...
...
Else
Block_n
End
3.6 Drawing of Flowchart
3.7 Nesting of If statements
3.8 Switch
1)
Switch (value)
case{1,3,5,7,9},
Block_1;
case{2,4,6,8},
Block_2;
...
...
otherwise
Block_n
End
3.9 Try_catch Structure
Try
Block_1
Catch
Block_2
End
3.10 multiple image windows and child windows
1) figure (n): Image window command;
2) subplot (m,n,p): The image window has m*n subwindow , p is the current operation window;
enhanced control of 3.11 images
1) Plot (X1,y1,linespec,..., xn,yn,linespec)
2) Plot (X1,y1,linespec, ' PropertyName ', PropertyValue)
3) linewidth: Used to specify the width of the line
4) Markeredgecolor: Used to specify the color of the logo surface
5) Markerfacecolor: Fill the color of the logo
6) markersize: Specify the size of the identity
Cases:
x =-pi:pi/10:pi;
y = tan (sin (x))-Sin (tan (x));
Plot (x, y, '--rs ', ' linewidth ', 3,...
' Markeredgecolor ', ' K ',...
' Markerfacecolor ', ' G ',...
' Markersize ', 10)
advanced control of 3.12 text
...
Chapter III Selection structure of MATLAB