Clear Filters
Clear Filters

I wan to solve an equation on MATLAB. It involves five variables. After using solve function i am getting answer in terms of those variables and not as a integer. I Want real value . How can i get that?

2 views (last 30 days)
syms Bw;
syms Rbwtobtf;
syms Hf;
syms Btf;
syms Mu;
syms d;
syms Fcu;
Bw=150;
Rbwtobtf=0.2;
Hf=70;
Btf=Bw/Rbwtobtf;
Fcu=30;
Mu=3400000000;
syms x;
d=solve('Mu==Fcu*Btf*x^2*(0.157*Rbwtobtf+(1-Rbwtobtf)*(Hf/x)*(0.45-0.225*(Hf/x)))',x);
here is the equation which i am unable to solve. Even double function is not giving the answer. please help.

Accepted Answer

John D'Errico
John D'Errico on 24 May 2017
Edited: John D'Errico on 24 May 2017
There is NO need to predefine variables as symbolic, then define them as numbers. So most of those syms calls were a waste of time.
Next, DON'T put the equation in quotes! At least, not if you want MATLAB to use those variables that you just defined.
Bw=150;
Rbwtobtf=0.2;
Hf=70;
Btf=Bw/Rbwtobtf;
Fcu=30;
Mu=3400000000;
syms x;
d=solve(Mu==Fcu*Btf*x^2*(0.157*Rbwtobtf+(1-Rbwtobtf)*(Hf/x)*(0.45-0.225*(Hf/x))),x);
>> d
d =
- (100*110955233^(1/2))/471 - 63000/157
(100*110955233^(1/2))/471 - 63000/157
vpa(d)
ans =
-2637.6919301059145700205777681076
1835.1441594052776273454185324388
Finally, that you want the result to be an integer is completely irrelevant. You can want anything in the world, but the solution is not an integer, and wishing won't make it so. If you then take the floor or ceil of the result, or round it, it won't be a solution anymore.

More Answers (2)

Torsten
Torsten on 24 May 2017
syms x
Bw=150;
Rbwtobtf=0.2;
Hf=70;
Btf=Bw/Rbwtobtf;
Fcu=30;
Mu=3400000000;
d=solve('Mu==Fcu*Btf*x^2*(0.157*Rbwtobtf+(1-Rbwtobtf)*(Hf/x)*(0.45-0.225*(Hf/x)))',x)
Best wishes
Torsten.
  3 Comments
Torsten
Torsten on 24 May 2017
Are you sure you didn't define the other variables (Bw,Rbwtobtf,...) as "syms" again ?
Best wishes
Torsten.
vinay mhatre
vinay mhatre on 24 May 2017
no i haven't defined them as "syms". also when i copy one of the row from ans and assign it to other variable manually then i get the exact ans. bt i want to put this expression in for loop so cant do it manually.
kindly help

Sign in to comment.


Walter Roberson
Walter Roberson on 24 May 2017
There are no integer solutions to those equations.
It is not very meaningful to ask for integer solutions to equations whose coefficients are approximate floating point numbers such as 0.157 . If you want integer solutions you should be using rational coefficients.
Note: there are no solutions to the equations if you convert the decimals into fractions of the appropriate power of 10, such as 0.157 being 157/1000.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!