Solving for two unknown variables

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Solving for two unknown variables

JMCB23
As I'm new to Octave and haven't used matlab in about 3 years, I'm just having a bit of trouble trying to solve for two unknowns simultaneously:

>> aa = 0.3;
>> S0 = 342.5;
>> ta = 0.53;
>> oo = 5.67e-8;
>> as = 0.11;
>> taa = 0.06;
>> aaa = 0.31;
>> c = 2.7;

(aa*S0)+(ta*S0)+(2*oo*Ta^4)+(taa*oo*Ts^4)+(aaa*oo*Ts^4)=(S0)+(as*ta*S0)+(c*(Ts-Ta)+oo)*(Ts^4)

As shown in the equation above, the two values I'm trying to find are that of Ta and Ts, however I'm not sure what function or coding to solve this equation. If anyone could assist me with this, that would be great. Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Solving for two unknown variables

Sebastian Schöps
JMCB23 wrote
As I'm new to Octave and haven't used matlab in about 3 years, I'm just having a bit of trouble trying to solve for two unknowns simultaneously:

>> aa = 0.3;
>> S0 = 342.5;
>> ta = 0.53;
>> oo = 5.67e-8;
>> as = 0.11;
>> taa = 0.06;
>> aaa = 0.31;
>> c = 2.7;

(aa*S0)+(ta*S0)+(2*oo*Ta^4)+(taa*oo*Ts^4)+(aaa*oo*Ts^4)=(S0)+(as*ta*S0)+(c*(Ts-Ta)+oo)*(Ts^4)

As shown in the equation above, the two values I'm trying to find are that of Ta and Ts, however I'm not sure what function or coding to solve this equation. If anyone could assist me with this, that would be great. Thanks!
I had a very quick look to your equation. Are you sure that that there is a solution and that the solution is unique? It's necessary to have as many equations as variables.

Let assume that the problem is well posed, then you have to rewrite your equation as a root-finding problem, i.e. "f(x) = 0", see https://en.wikipedia.org/wiki/Root-finding_algorithm.

So, after having declared you variables, this may look in Octave like this

f=@(x) ((aa*S0)+(ta*S0)+(2*oo*x(1)^4)+(taa*oo*x(2)^4)+(aaa*oo*x(2)^4)-(S0)+(as*ta*S0)+(c*(x(2)-x(1))+oo)*(x(2)^4));

If you are lucky, fsolve will give you a a good approximation of the answer (read: "help fsolve").

Seb.