Solve and save the value in a variable

7 次查看(过去 30 天)
Hi, I'm very new to matlab and I have a problem I'm trying to solve. I need to get first value answer of 0.15=m(1-sqrt(m/3)) This will have two solutions and I need to save the first solution in a variable m.
This is part of a bigger program that I'm trying to write.
I need a numerical answer of about 4 digits that I can use to solve other equations. the value should be 0.2027.

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2014-4-1
sol=solve('0.15==m*(1-sqrt(m/3))')
  2 个评论
Kartavya
Kartavya 2014-4-1
Hi, Thank you for the quick response. That gives out:
2.6727127692184218126953766245785 - 5.7397185098744507225035963731555e-42*i 0.20268197819238525035246158863262 + 1.6193360453887443134686542994198e-40*i
However, I'm only interested in the 0.20268 part without the imaginary things attached. Anyway I can do that? Also the 0.15 coming in is from another variable. So far I have:
syms x;
m=solve(xf==x*(1-sqrt(x/3)),x)
Which gives me the exact value and not in proper form I can use for other equations.
Azzi Abdelmalek
Azzi Abdelmalek 2014-4-1
To get the real part of the second solution use
double(real(sol(2)))

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by