
The bright moon in my heart shines clearly, traveling thousands of miles.
Rarely have leisure during the holidays.
While enjoying the holiday,
why not sit down quietly and unlock a new skill?
Join the “Practical Knowledge” social practice team
and open the door to MATLAB.
Unveil the mysterious veil of mathematical modeling.
Here is the first session of MATLAB knowledge sharing.
1. Composition of the MATLAB Operating Interface
1. MATLAB Main Window
2. MATLAB Command Window
Used for inputting commands and displaying command execution results.
Command prompt:Promptcan receive and execute commands.
Continuation character: Treat the next line as alogical continuation
Clear: Input command clc
3. Current Folder Window:
The folder used during MATLAB work; to facilitate file management, users can set their own folder as the current folder.
Set current folder
(1) Select a folder as the current folder in the Current Folder Toolbar or Current Folder Window.
(2) Use the cd command.
Note:First create a folder on the disk,then use the command.
4. Workspace Window: Displays and operates variables; it can also be used to save, edit, and delete variables.
5. MATLAB Search Path:
Command object search path
Set file search path
Use path command to set the file search path. For example: path(path, ‘e:\work’)
Set file search path using dialog box.

2. MATLAB Numerical Data
Data Type Classification
1. Integer
Integer data is divided into unsigned integers and signed integers, which are further divided into 8-bit, 16-bit, 32-bit, and 64-bit.
Data conversion function, e.g., uint8 function converts to unsigned 8-bit integer.
2. Floating Point
Floating point is divided into single precision (occupying 4 bytes) and double precision (occupying 8 bytes), so double precision data has higher precision.
In MATLAB, double precision is the default.
single function: converts to single precision.
double function: converts to double precision.
3. Complex
Complex data includes real and imaginary parts, both default to double precision. The imaginary unit is represented by i.
real function: obtains the real part of a complex number.
imag function: obtains the imaginary part of a complex number.

3. Common Mathematical Functions
1. Function Call Format:
Function name (function variable value)
2. Common Functions
(1) Trigonometric Functions: in radians and degrees (functions in degrees are distinguished by adding ‘d’ to the function name, e.g., sin(pi/2) sind(90)).
(2) abs function: can obtain the absolute value of real numbers, modulus of complex numbers, and ASCII code values of strings.
Functions for rounding: fix, floor, ceil, round.
(3) round function: rounding rules for integer conversion.
(4) ceil function: rounding up, taking the first integer greater than or equal to this number.
(5) floor function: rounding down, taking the first integer less than or equal to this number.
(6) fix function: fixed rounding to the integer closest to 0, that is, truncating decimals.

4. MATLAB Variables and Assignment Statements
1. Variable Naming: In MATLAB, variable namesmust start with a letter, followed by letters, digits, or underscores, with a maximum of 63 characters.
Note: Variable names distinguish between uppercase and lowercase letters.
Standard function names must be in lowercase letters.
2. Assignment Statements:
Variable = Expression
Predefined variables:The system itself defines variables (avoid redefining them when using).
ans:Default assignment variable.
i and j: imaginary unit.
Pi: represents the value of pi.
NaN: Not a Number.
3. Variable Management
Deleting and modifying memory variables (right-click the variable name in the workspace window to modify).
who and whose commands.
Memory variable files: used to save MATLAB workspace variables, with the extension .mat, also called MAT files.
save command:Creates a memory variable file.
load command:Loads a memory variable file.
For example: save mydata a x (saves variables a and x into mydata.mat file).
load mydata (loads the mydata file into the workspace, variables a and x can be used directly).

Good luck lies in hard work, happiness comes from sweat.
Phased learning arrangements.
Small assignments to consolidate knowledge.
Why not join in and improve together?
Don’t just stop at the thought, take action quickly.

Images and Text | “Practical Knowledge” Research Team
Editor | Lu Hongyu
Chief Editor | Cao Jun