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 次查看(过去 30 天)
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.

采纳的回答

John D'Errico
John D'Errico 2017-5-24
编辑:John D'Errico 2017-5-24
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.

更多回答(2 个)

Torsten
Torsten 2017-5-24
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 个评论
vinay mhatre
vinay mhatre 2017-5-24
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

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2017-5-24
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.

标签

Community Treasure Hunt

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

Start Hunting!

Translated by