Tips for Matlab Equation
When organizing or calculating complex expressions, I have now become a body that cannot be solved without the Matlab.
I will introduce some useful functions with examples when using Matlab, an all-around calculator for engineering students.
1. Generate Character Variables | syms
Use it when you want to express variables in an equation. Let's not make a mistake of putting = after syms.
syms x1 x2
y = x1 + x2 + 1
2. Finding Root of Equation, Organizing Formula | solve
It's good when you're looking for the solution of an equation. It can be entered in the form of solve(equation, variable).
syms x
f = x^2 - 4 == 0;
solve(f,x)
It can also be used to organize specific variables. The following is the result of equation f for x1.
syms x1 x2
f = x1^2 +x2 - 4 == 0;
x1 = solve(f,x1)
3. Substitute Value for Character variable, Replace Variable | subs
The equation can be calculated by substituting value for character variable created using syms.
syms x
f = x^2 - 4;
f_4 = subs(f,x,4)
Of course, it is also possible to replace it with other character variable.
syms x t
f = x^2 - 4;
f_t = subs(f,x,2*t)
4. Organizing the order of variables | collect
It is useful when you want to organize into specific variables in a compelx equation.
syms x y
coeffs_x = collect(x^2*y + y*x - x^2 - 2*x, x)
coeffs_y = collect(x^2*y + y*x - x^2 - 2*x, y)
5. To Express at a Glance Easily | pretty
The name of the function is pretty. Draw complex formulas easily.
syms x
f = sqrt(x^2 + 1)/(2*x + 4);
pretty(f)
Even if you know this much, I think it's good for you to write reports or papers at school. I hope you use it usefully when you are too lazy to write by hand or when you don't believe in your calculations.
'유용한 지식 > Matlab' 카테고리의 다른 글
Tips for Matlab Matrix (0) | 2020.09.24 |
---|---|
Get Matlab Excel Data | xlsread function (0) | 2020.09.24 |
Using the Matlab 'for Statement' | Loop Statement (0) | 2020.09.24 |
Using Matlab 'if Statement' | Assumption Statement (0) | 2020.09.24 |
Matlab Graph Axis Tick | Plot Advanced Edit1 (0) | 2020.09.24 |
댓글