MATLAB Extremely basic question for MATLAB's solve()

  • Thread starter Thread starter BilalX
  • Start date Start date
AI Thread Summary
The discussion centers on solving an equation in MATLAB using the solve() function, specifically when dealing with symbolic variables. The original poster encountered a problem where the command returned a warning about not finding an explicit solution when using symbolic variables. They successfully solved the equation by substituting numerical values directly but sought a method to perform the operation without manual substitution. A solution was provided, suggesting the use of the subs command to substitute defined variables into the equation before solving. This approach allows for the equation to be solved symbolically while keeping the variables defined as doubles, thus addressing the issue of the initial warning and empty answer set.
BilalX
Messages
7
Reaction score
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
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.
 
Any solutions for this issue?
 
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.
 

Similar threads

Replies
4
Views
3K
Replies
4
Views
11K
Replies
4
Views
3K
Replies
1
Views
4K
Replies
3
Views
3K
Replies
3
Views
15K
Replies
1
Views
2K
Back
Top