| Thread Closed |
Temperature Change in Matlab |
Share Thread | Thread Tools |
| Aug10-09, 05:00 PM | #1 |
|
|
Temperature Change in Matlab
I'm very confused on about solving the following question using Matlab:
A drink cools according to the difference equation: Tn=Tn-1-0.02(Tn-1-Ta) Where Tn is the temprature after n minutes. When you pour the drink it's 80 degrees. After you have poured it you leave it for 15 minutes in the kitchen where the air temprature is 20 degree, then you take it outside where the temprature is 12 degrees. Calculate the temprature of the drink afte it has been outside for 15 minutes. This is my script: Code:
k=0.02; T_a=12; S(1)=80; S_a=20 for n=1:15 S(n+1)=S(n)-k(S(n)-S_a); T(1)=S(16); T(n+1)=T(n)-k(T(n)-T_a); end T(16) |
| Aug10-09, 05:12 PM | #2 |
|
Mentor
|
I'm no expert at MATLAB, but it looks like there are two problems. First, it doesn't seem to be parsing k(S(n)-S_q) as a multiplication of k * whatever. Looks like it thinks it's an array access?
And I don't see how you have two separate loops of 15 minutes each -- seems like you need to to the first 15 minutes, and then do another 15 minutes with the different delta-Temperature... |
| Aug11-09, 01:48 PM | #3 |
|
|
Code:
k=0.02; T_a=12; S(1)=80; S_a=20 for n=1:15 S(n+1)=S(n)-k*(S(n)-S_a); T(1)=S(16); T(n+1)=T(n)-k*(T(n)-T_a); end T(16) ![]() I think I need to have two separate loops for each 15 minutes because in the first 15 minutes the drink is placed in a room with a temperature of 20° and in the second 15 minutes it's placed outside where the temperature is 12°... |
| Thread Closed |
| Thread Tools | |
Similar Threads for: Temperature Change in Matlab
|
||||
| Thread | Forum | Replies | ||
| Kelvin Temperature - Celsius Temperature Change | General Physics | 12 | ||
| Change in Temperature | Advanced Physics Homework | 9 | ||
| Chemistry: Finding a temperature change using a temperature/gram ratio | Biology, Chemistry & Other Homework | 3 | ||
| Temperature Change | Introductory Physics Homework | 9 | ||
| Temperature change, temperature derivative of material? | General Physics | 0 | ||