- You can make D symbolic for the purpose of the equation, and solve for x with respect to the symbolic variable D, and then you can subs() the vector of numeric D values into the solution to get out a vector of x values; OR
- You can call solve() once for each of the separate equations in the vector eqn.
- You can read the equations and realize that you can express the equations as a quadratic. You can then use the standard quadratic formula in vectorized form to get the solutions for D
- You can read the equations and realize that you can express the equations as a quadratic. You can then call roots() once with appropriate numeric coefficients for each D value to get out the two corresponding x values.
can't find the solution of the equation
3 views (last 30 days)
Show older comments
xihao zeng
on 28 Sep 2020
Commented: xihao zeng
on 29 Sep 2020
syms x
m1=5.97*10^24;
m2=7.35*10^22;
D=linspace(3.8*10^8,4.0*10^8,41);
eqn=m1.*((D-x).^2)==m2*(x^2)
solx(eqn,x)
0 Comments
Accepted Answer
Walter Roberson
on 29 Sep 2020
D is a vector, so your eqn is a vector.
When you pass more than one equation to solve(), then you are asking solve() to find the values of the unknowns that satisfy all the equations at the same time. For example,
solve([x^2+y^2==17, x+y=11])
does not ask solve() to find the x and y that solve each of the two equations independently: it asks for the x and y pairs that solve all of the equations.
But there is no single x value that solves all 41 of your equations simultaneously.
You have several choices:
More Answers (0)
See Also
Categories
Find more on Equation Solving in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!