Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Solving 3 equations in Matlab

Subject: Solving 3 equations in Matlab

From: amadd

Date: 29 Nov, 2010 19:21:12

Message: 1 of 8

Hello, I`m having trouble solving equations simultaneously in Matlab. I have three equations and three unknowns. Two equations are algebraic and one is a differential equation. Here are my three equations, any help would be appreciated:

1. (0.3*1.06*3348*Ttank)-(0.3*1.06*3348*Toutc)+(20*200*(sin(t/24*3.14))^8=0

2. (0.041*4418*20)-Toutw*4418*0.041+1000*((Ttank-20)-(Ttank-Toutw))/ln(Ttank-20)/(Ttank-Toutw)

3. 1.06*3348*1.5* dTtank/dt=0.03*1.06*3348*Toutc-0.03*1.06*3348*Ttank-1000*((Ttank-20)-(Ttank-Toutw))/ln(Ttank-20)/(Ttank-Toutw)

t is time and will simulate from 0 until 300. Intial condition for Ttank(0)= 40, so Ttank at 0 is equal to 40. Please I need help urgently. How can this be written in Matlab and how can we plot Toutw against t (time)? I would really appreciate any help.

Subject: Solving 3 equations in Matlab

From: Walter Roberson

Date: 29 Nov, 2010 20:22:04

Message: 2 of 8

On 10-11-29 01:21 PM, amadd wrote:
> Hello, I`m having trouble solving equations simultaneously in Matlab. I have three equations and three unknowns. Two equations are algebraic and one is a differential equation. Here are my three equations, any help would be appreciated:
>
> 1. (0.3*1.06*3348*Ttank)-(0.3*1.06*3348*Toutc)+(20*200*(sin(t/24*3.14))^8=0

The '(' before the 20 is not matched to anything. It is redundant if the close
bracket goes after the ^8, but would have a large difference if the close
bracket goes immediately before the ^8.
>
> 2. (0.041*4418*20)-Toutw*4418*0.041+1000*((Ttank-20)-(Ttank-Toutw))/ln(Ttank-20)/(Ttank-Toutw)
>
> 3. 1.06*3348*1.5* dTtank/dt=0.03*1.06*3348*Toutc-0.03*1.06*3348*Ttank-1000*((Ttank-20)-(Ttank-Toutw))/ln(Ttank-20)/(Ttank-Toutw)
>
> t is time and will simulate from 0 until 300. Intial condition for Ttank(0)= 40, so Ttank at 0 is equal to 40. Please I need help urgently. How can this be written in Matlab and how can we plot Toutw against t (time)? I would really appreciate any help.

Your only obvious function in the set of equations is Ttank(t), but you ask to
graph Toutw vs t, which implies that Toutw is a function of t. That then leads
us to the question of whether Toutc is also a function of t or is a constant?

If Toutw(t) is what the set of equations is to be solved for, then equation 1
and the initial condition on Ttank(0) do not contribute to the solution
(because they are independent of Ttoutw(t)). Solving without them gives the
result that the equations 2 and 3 are inconsistent for arbitrary Ttank(y), and
that is the case whether Toutc is treated as a constant or a function of t.

If Toutw and Toutc are left as constants, then Maple's differential equation
solver reports there is no solution (but that might mean instead that Maple
does not know how to find the solution -- I did not go far enough to establish
one way or the other.)

It would help if you were to reply showing _exactly_ what is being used as a
function (and fixing up the bracket.) For example, in equation 1, since Ttank
must be a function of t, write that explicitly,

(0.3*1.06*3348*Ttank(t))-(0.3*1.06*3348*Toutc)+(20*200*(sin(t/24*3.14))^8)=0

and likewise explicitly indicate any other functions. Doing so will reduce the
ambiguities in the questions.

I suggest, by the way, that you replace the 3.14 with pi . Remember,
sin(t*3.14) is going to have different behaviour than sin(t*pi).

If you have the constants to higher precision, then it would probably be
better to use those higher precision values.

Subject: Solving 3 equations in Matlab

From: amadd

Date: 29 Nov, 2010 20:54:11

Message: 3 of 8

Thank you very much for your help. The equations are as they are. Ttank is a function of time. Toutw is dependant on Ttank and is considered a constant.I have tried running this model using Maple but it didn`t work. I`ll explain that this is a model for a solar collector that transfer heat to water in a tank. Ttank is the temperature of the fluid in the tank, this transfer heat to water in a pipe. I am to model the temperature increase of water over time. My equations are 100% correct, but you are right, I should replace 3.14 with pi. But, the main problem is that I do not know how to model them in matlab. Can you provide me with an answer now or do you need more help or information. I appreciate your reply.

Subject: Solving 3 equations in Matlab

From: amadd

Date: 29 Nov, 2010 20:56:52

Message: 4 of 8

By the way Toutw is not be modelled differentially over time. But it is dependant on the Ttank (temperature of the tank) for increase as you can see from the 2nd equation which is:

(0.041*4418*20)-Toutw*4418*0.041+1000*((Ttank-20)-(Ttank-Toutw))/ln(Ttank-20)/(Ttank-Toutw)

Subject: Solving 3 equations in Matlab

From: Walter Roberson

Date: 29 Nov, 2010 21:36:06

Message: 5 of 8

On 10-11-29 02:54 PM, amadd wrote:
> The equations are as they are. Ttank is a function of time. Toutw is dependant on Ttank and is considered a constant.

I am having difficulty understanding that. If Ttank is a function of time, and
Toutw is dependant on Ttank, then Toutw must also be a function of time unless
there is a boundary condition that forces it to a particular value.


> I have tried running this model using Maple but it didn`t work.

Maple can only do what it is told, and I don't think you are telling it to do
the right thing.


What does Toutc represent in your model? Is it a constant?

Poking around, it appears possible that there are two different solutions to
the problem, one in which Toutw is constant at 20, and the other of which in
which Toutw is a complicated function involving logs of Toutc and sin(t).
The one in which Toutw is constant at 20 appears to have a solution for all
Toutc at approximately -11.85 seconds (though I have not cross-checked the
Ttank(0) boundary condition for it.) The other one, with Toutw a function of
time, would require Toutc to also be a function of time in order to be meaningful.

Subject: Solving 3 equations in Matlab

From: Roger Stafford

Date: 29 Nov, 2010 23:49:05

Message: 6 of 8

amadd <amardi88@gmail.com> wrote in message <1735798820.23823.1291058514512.JavaMail.root@gallium.mathforum.org>...
> Hello, I`m having trouble solving equations simultaneously in Matlab. I have three equations and three unknowns. Two equations are algebraic and one is a differential equation. Here are my three equations, any help would be appreciated:
>
> 1. (0.3*1.06*3348*Ttank)-(0.3*1.06*3348*Toutc)+(20*200*(sin(t/24*3.14))^8=0
>
> 2. (0.041*4418*20)-Toutw*4418*0.041+1000*((Ttank-20)-(Ttank-Toutw))/ln(Ttank-20)/(Ttank-Toutw)
>
> 3. 1.06*3348*1.5* dTtank/dt=0.03*1.06*3348*Toutc-0.03*1.06*3348*Ttank-1000*((Ttank-20)-(Ttank-Toutw))/ln(Ttank-20)/(Ttank-Toutw)
>
> t is time and will simulate from 0 until 300. Intial condition for Ttank(0)= 40, so Ttank at 0 is equal to 40. Please I need help urgently. How can this be written in Matlab and how can we plot Toutw against t (time)? I would really appreciate any help.
- - - - - - - - - -
  In equation 1 the quantity Toutc can easily be solved in terms of t and Ttank. In equation 2 Toutw would be the solution of a quadratic equation whose coefficients depend on Ttank. This has two solutions, so you will have to decide which one is to be used.

  Thus you can run this as a single differential equation using equation 3 with Ttank the dependent variable and t the independent variable. Where Toutc and Toutw occur in equation 3 you can express them as functions of Ttank and t as described in the first paragraph.

  You can obtain Toutw as a function of t because it is a function of Ttank which is a function of time and which the 'ode' routines hand back to you.

  You would make life easier for yourself if you first do a little simplification of those messy equations. You can figure out such products as 0.3*1.06*3348 on your hand calculator. Also in ((Ttank-20)-(Ttank-Toutw)) the Ttank's apparently cancel each other. Be sure to write 'log' rather than 'ln' for matlab's natural logarithm.

Roger Stafford

Subject: Solving 3 equations in Matlab

From: amadd

Date: 30 Nov, 2010 00:28:55

Message: 7 of 8

Hi, I will explain the system to you in further details:

1. Their is a fluid that is heated by a solar collector at the rate of 20*200*(sin(t/24*pi)^8 where t is time in hours. The Ttank is the temperature of the tank, the Toutc is the temperature of the fluid after it has been heated by the solar collector. So, the fluid gains heat from the collector and transfers it to the tank with time. The tank then transfers the heat it has gained from the collector to water running in pipes that passes through it. So, as time increases all three temperatures change. The constants and boundary conditions are that

1. water inlet is always at 20 C
2. heat exchange rate between the tank and pipe is constant at 1000 W/C
3. T intial of the tank is 40

However, the water and collector are in steady state(equation is equal to zero) and the tank is in a dynamic state in which a differential equation depicts its behavior with time. Can I clarify further? Do you know how it can be modelled now? Please let me know so I can assist you as best as I can. Again, thanks for your help.

Subject: Solving 3 equations in Matlab

From: amadd

Date: 30 Nov, 2010 00:47:44

Message: 8 of 8

By the way regarding your question about logarithms, the log mean temperature difference is used to show the temperature change between the tank and the water pipe. It is present in the differential equation and the water pipe equation(3). It simply that (Ttank-Twaterin(20C)-(Ttank-Twaterout(toutw)/ln(Ttank-Twaterin(20C)/(Ttank-Twaterout(toutw). Toutw is the temperature of the water outlet, Twaterin is the temperature of the water inlet which is constant at 20 and Ttank is the varying temperature of the tank with time. Anymore details I can provide?

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us