Chapter one MatLab overview
1-1 Matlab common commands and shortcut keys
CLF clear the figrue image 4. Path displays the search path 5. Exit exit Matlab 6. Quit Exit Matlab 7. Who and WHOS 8. Mkdir Create a directory rmdir Delete a directory 11. PWD display the current working directory 12. What display M, MAT, MEX files in the current directory 13 Pack collects memory fragments. 16. Path or genpath Displays the search path. 17. Helpdesk open a help window in a browser. 22. Doc = help, Doc sin in the help window to display the results of the function query. Demo in the help window to display the example program shortcut Alt + Backspace to restore the last deleteCopy the code
1-2 Matlab foundation
Command line window workspace History command window search pathCopy the code
Chapter two Matlab foundation
2-1 Basic data types of MatLab
The data type | instructions |
---|---|
Int8, int16, int32, int64 | Signed shaping |
Uint8, UINT16, uint32, uint64 | Unsigned shaping |
single | Single-precision floating point type |
double | A double precision floating point type |
logical | logical |
char | String form |
cell | Element array |
struct | Structure form |
function_handle | Function handle shape |
A total of 15 kinds of
Take the integral function of 2 minus 2
Round is rounded to the nearest integer. If it contains 0.5, fix with the largest absolute value is rounded to 0. In other words, the nearest integer whose fractional part floor is not greater than or equal to ceil is not less than or equal to ceil is discardedCopy the code
2-3 realmin and realmax
Realmin () Realmax () input must be 'single' or 'double'Copy the code
2-4
function | instructions |
---|---|
complex(a,b) | Create complex numbers where a is the real part and b is the imaginary part |
real(z) | I get the real part of the complex number z |
imag(z) | I get the imaginary part of the complex number z |
abs(z) | I get the magnitude of the complex number z |
angle(z) | I get the Angle of the complex number z |
conj(z) | I get the complex conjugate of z |
A total of 6
2-5 Logical type
> > true (3, 4) ans = 3 x 4 logical array 1 1 1 1 1 1 1 1 1 1 1 1 > > false (3) ans = 3 x 3 logical array 0 0 0 0 0 0 0 0 0Copy the code
Logical () can be used to convert numeric types to logical types
2-6 characters and strings
>> a=[65 66 67 68] a= 65 66 67 68 >> c=char(a) c= 'ABCD' >> d=int8(c) d= 1×4 int8 row vector 65 66 67 68Copy the code
Chapter 3 Arrays and their operations
Basic use of 3-1 arrays
>> A=[1 2 3 4 5]
A =
1 2 3 4 5
>> b1=A(3)
b1 =
3
>> b2=A(2:4)
b2 =
2 3 4
>> b3=A(3:end)
b3 =
3 4 5
>> b4=A(3:-1:1)
b4 =
3 2 1
>> b5=A(end:-1:1)
b5 =
5 4 3 2 1
>> b6=A([2 4])
b6 =
2 4
Copy the code
3-2 Create arrays using colons
>> A= 2:6a =2 3 4 5 6 >> B= 2.5:10.9B = 2.5000 4.5000 6.5000 8.5000 10.5000 >> C= 2.3:2:9.9C = 2.3000 4.3000 6.3000 8.3000 >> D=8:-2:1 D=8 6 4 2 >> E=2:-2:6 E= empty 1×0 double row vectorCopy the code