Info

This question is closed. Reopen it to edit or answer.

Having problem about matlab code

1 view (last 30 days)
Redwood
Redwood on 31 Aug 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
Dear Matlab experts,
I would like to get x and y. Here is my coding below. Please solve this problem. Thank you very much in advance.
Sincerley yours,
J1
syms x y
A = 5;
B =10;
C = 6;
D = 3;
sol = solve(x*(1-exp(-y*B))==A, x*(1-exp(-y*D))==C, x, y)
  1 Comment
Stephen23
Stephen23 on 31 Aug 2015
@Redwood: I just formatted your code for you, but in future you can do it yourself very easily: select the code and click the {} Code button that you will find above the text box.

Answers (1)

Walter Roberson
Walter Roberson on 31 Aug 2015
What difficulty are you encountering with that code?
The solutions are algebraically of the form
T = RootOf(6*Z^9 + 6*Z^8 + 6*Z^7 + 6*Z^6 + 6*Z^5 + 6*Z^4 + 6*Z^3 + Z^2 + Z+1, Z)
x = -(26/15)*T^8-(52/15)*T^7+(4/5)*T^6-(14/15)*T^5-(8/3)*T^4+(8/5)*T^3-(2/15)*T^2-(19/45)*T+238/45
y = -ln(T)
where RootOf(f(Z),Z) represents the set of values, Z, such that f(Z) = 0 -- that is, the roots of the expression.
As the polynomial is of order 9, there is no closed form formula for representing the roots. You can represent them by placeholders like this, or you can evaluate them numerically. There are 9 different roots, so there are 9 different solutions for your x and y. 8 of the 9 roots are complex valued and one of them is real valued, but the real-valued root is negative so ln() of it is complex so all of the y are complex. With one of the roots being real-valued, one of the x is real-valued.
I would expect that you are getting back a symbolic result that has the same meaning as the above. You can apply mathematical reasoning to the roots, but they are not very meaningful to humans unless you take their numeric values. You can do that using vpa() or using double()
double(sols.x)

Community Treasure Hunt

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

Start Hunting!