How I should make a loop for coefvct's roots?

1 view (last 30 days)
I am trying to calculate the following formula using Matlab:
x = 34.704 - 0.34 * 10^-8 * [(x+273)^4-(r+273)^4] + 1.1 * h * (x - T)
h= 2.38 * (x - T) ^ 0.25 , for 2.38 (x - T) ^ 0.25 > 12.1 * u ^ 0.5
h= 12.1 * u ^ 0.5 , for 2.38 (x - T) ^ 0.25 < 12.1 * u ^ 0.5
r = ( (G+273)^4 + 2.5 * 10^8 * u^ 0.6 * (G - T) ) ^ 0.25 - 273
G= 0.5 * r + 0.5 * T
i= 1 : 10, and x= (x1, x2, ..., x 10) , r= (r1, r2, ..., r10), h= (h1, h2, ..., h10), T= (T1, T2, ..., T10), u = (u1, u2, ..., u10), G = (G1, G2, ..., G10)
I am trying to find x, which I reckon I should use coefvct for finding roots, but it is complicated to connect x and other parameters.
It would be much appreciated if you could please advice me regarding this matter.

Accepted Answer

Divya Yerraguntla
Divya Yerraguntla on 27 Aug 2019
Hi Nima,
It is not always necessary to create a coefficient vector and use roots function to solve a polynomial equation. You could use vpasolve function from Symbolic Math Toolbox, which takes in the entire equation as the input argument. Have a look at this link for more information about vpasolve function.
You can have a look at this question, especially its extended questions in comments to create loops to solve equations with changing variables or variable vectors.
Hope it helps!

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!