How to use matlab to solve equation
1. Preface
As one of the three major mathematical software, Matlab is the best in numerical calculation. Solving equations is the most basic and common problem in engineering study and engineering calculation. It is very important to master the method of solving equations with modern tools to improve our engineering literacy. Therefore, this paper will introduce the method of solving equations in MATLAB.
2. Usage
solving process
2.1 – indicated variables
Tell the computer the variables contained in the equation, including parameters and unknown variables. For example, the equation to be solved is: obviously, there are symbolic variables a, B, C and X in the equation, so the writing method of this step is:
syms a b c x |
2.2 specify equations, unknowns and constraints (not required)
If there is more than one equation,
eqns | put it in [] and separate it with a comma. For example: |
vars | unknowns to be solved |
Names value (not required) | Names: “return conditions” returns the general solution with parameters. ” If ‘true’ is returned and ‘false’ is not, a special solution is given; |
Name: ‘ignoreanalytical constraints’ is the simplest form of the solution given. ‘true ‘is yes and’ false ‘is no | |
Name:’ principalvalue ‘only gives one solution. False is to return all solutions, true is to return only one solution; | |
Name: ‘real’ only returns real solutions |
2.3 obtain the solution of the equation
If there are multiple functions, the solution is stored as a structure.
3. Specific examples
3.1 = general solution of sin (x) = 1
Specific code:
syms x [x,params,conds]=solve(sin(x)==1,’ReturnConditions’, true) |
result
solx =pi/2+2*pi*k params =k conds =in(k,’integer’) |
It can be seen that the general solution of the equation is as follows:
3.2 solve the following equation:
code:
syms a b c y x [x,y]=solve([a*x^2+b*y+c==0,a*x+2*y==4],[x,y]) |
result:
x = ((a*b)/4-(-(a*(- a*b^2+32*b +16*c))/16)^(1/2))/a ((a*b)/4+(-(a*(- a*b^2+32*b +16*c))/16)^(1/2))/a y = (-(a*(- a*b^2+32*b +16*c))/16)^(1/2)/2-(a*b)/8+2 2-(-(a*(- a*b^2+32*b +16*c))/16)^(1/2)/2-(a*b)/8 |
Namely:
Read More:
- How to Solve differential equations with MATLAB
- How to use matlab xlswrite
- How to Solve failed Precondition Error: attempting to use uninitialized value beta1_power
- How to use vimdiff to solve conflict?
- How to solve oserror: [errno 98] address already in use and kill the python3 process
- How to wrap a long string in MATLAB
- How to express ln function in MATLAB?
- FTP use get command 550 failed to open file, but use the put command to solve the problem
- The @ Autowired annotation in springboot is invalid in ordinary classes. How to solve and use the null pointer exception java.lang.nullpointerexception
- C#: How to Use Httpclient to upload files with other parameters
- How to Use Truffle to Deploy contracts on moonbeam
- Matlab: successfully solve too many input arguments
- Tensorflow: How to use expand_Dim() to add dimensions
- Develop a Boolean equation for overflow detection
- How to use torch.sum()
- How to use Latex to Write Matrices
- How to use C # to get image format without system. Drawing. Common
- How to use latex argmin argmax subscript
- How to Use qdbusinterface to call DBUS interface
- How to use JavaScript in HTML