Extremely basic question for MATLAB's solve()

  • MATLAB
  • Thread starter BilalX
  • Start date
In summary, the conversation discusses a problem with using the solve() function in MATLAB to solve an equation with variables. The user has found that the function works when manually entering numerical values for the variables, but they are looking for a solution that does not require explicitly entering the values. Another user suggests using the subs command to enter the variables and then using the solve() function.
  • #1
BilalX
7
0
Hello,

Although I recently had a MATLAB class it didn't really touch on variable types or use of the solve() function, and now I'm stumped on an embarrassingly basic problem; I'm trying to solve an equation in this form, with the other variables defined as doubles:

solve('Dy*sin(Cy*atan(By*alpha1-Ey*(By*alpha1-atan(By*alpha1))))+Svy=2131','alpha1')

This returns an "Explicit solution could not be found" warning and an empty answer set. From what I've been able to gather, the command attempts to solve the equation symbolically, and it works fine when I manually replace the variables with their numerical values, e.g:

solve('2119.16*sin(1.2739*atan(11.981*alpha1-0.0012*(11.981*alpha1-atan(11.981*alpha1))))+27.6617=2131','alpha1')

Could anyone tell me how to make the command work without having to explicitly enter the numerical values?
 
Physics news on Phys.org
  • #2
I think they use two different tool boxes, so they can't really be mashed together. I tried to do this the other day but couldnt.
 
  • #3
Any solutions for this issue?
 
  • #4
perhaps a bit late, but I have an answer to your question. as I was looking into it myself and needed an answer as well.
You can use the subs command to enter your variables.

DyS = some formula
ByS =
SvyS =
EyS =
CyS =

Eq='Dy*sin(Cy*atan(By*alpha1-Ey*(By*alpha1-atan(By*alpha1))))+Svy=2131';

subs(Eq,Dy,DyS);
subs(Eq,By,ByS);
subs(Eq,Svy,SvyS);
subs(Eq,Ey,EyS);
subs(Eq,Cy,CyS);

solve(Eq,'alpha1')
% or [alpha1] = solve(Eq,'alpha1')

There may be a more elegant solution, but this works.
 
  • #5


Hello,

The solve() function in MATLAB is used to find symbolic solutions to equations. In order for it to work, all variables in the equation must be defined as symbolic variables. In your case, it seems that the variables D, B, C, E, and alpha1 are not defined as symbolic, which is why the function is not able to find a solution. To make the command work, you can define these variables as symbolic using the syms function in MATLAB. For example, you can write syms D B C E alpha1 before the solve() command, and then the function should be able to find a solution without explicitly entering numerical values. I hope this helps.
 

What is the purpose of MATLAB's solve() function?

MATLAB's solve() function is used to solve algebraic equations and systems of equations. It can also be used to find the roots of a polynomial, the inverse of a matrix, and the solution to a differential equation.

How do I use the solve() function in MATLAB?

To use the solve() function, you need to define the equation or system of equations you want to solve using symbolic variables. Then, you can input the equation(s) into the solve() function along with the variables you want to solve for. For example, if you have the equation x + 2 = 5, you can input solve('x + 2 = 5', 'x') to solve for the value of x.

Can the solve() function solve equations with multiple variables?

Yes, the solve() function can solve equations with multiple variables. You can input a system of equations into the function, with each equation separated by a comma. Additionally, you can specify which variables you want to solve for by including them in the second input of the function.

What happens if there is no solution to the equation(s) input into the solve() function?

If there is no solution to the equation(s), the solve() function will return an empty symbolic array. This means that there is no numeric solution to the equation(s) being solved.

Can I use the solve() function to solve both linear and non-linear equations?

Yes, the solve() function can be used to solve both linear and non-linear equations. It uses a variety of numerical and analytical methods to solve different types of equations, so it is suitable for a wide range of mathematical problems.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
10K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
7K
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
5K
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
14K
Back
Top