1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Unsolvable matlab problem

  1. May 14, 2012 #1
    1. The problem statement, all variables and given/known data
    Process description
    The system of interest is a multi‐purpose batch unit used for cooling, decantation and storage. This
    kind of unit is used worldwide in a range of industries and there are many design variations. The
    particular unit of interest is located under cover, is sheltered from weather events and does not
    receive any direct solar radiation. The air velocity in the vicinity of the unit is below detectable limits
    (<0.1 m/s). The unit is shown in its normal operating environment in Figure 1. The operating
    procedure of the unit is as follows:
     The vessel is initially empty and at ambient temperature.
     The unit is charged with a batch of hot process fluid.
     The unit is allowed to cool until the process fluid is within ~2°C of ambient temperature.
     At the end of cooling step, the process fluid is decanted and the vessel is cleaned.
    A series of plant trials have been conducted to collect data for model validation and possibly
    calibration purposes. Figure 2 shows the unit undergoing testing.

    ***the vessel is a coffee cup, cooling to room temperature

    6 different experiments were conducted and the data given to us for comparisons sake.

    in regards to the code

    Ti = the ambient air temperature (average)
    T = temperature of coffee at given time (t)
    lam = heat transfer coefficient (λ)

    2. Relevant equations

    dT/dt = -λ(T-Ti)
    C = T - Ti
    λ = ln(u)/(t*ln(C*Ti))

    3. The attempt at a solution

    Code (Text):
    Script file:

    %Ti=[27.7 26.66 28.2 20.8 21.54 22.8];



    p={ Ti1, Ti2, Ti3, Ti4, Ti5, Ti6};
    y0 = [T1o, T2o, T3o, T4o, T5o, T6o];

    %, lam1, lam2, lam3, lam4, lam5, lam6

    interval = 1;
    tspan= [0 : 1 : 360]; %#ok<NBRAK>

    [t,y] = ode45(@(t,y) function3(t,y,p),tspan,y0);

    T1 = y(:,1);
    T2 = y(:,2);
    T3 = y(:,3);
    T4 = y(:,4);
    T5 = y(:,5);
    T6 = y(:,6);

    %Solve Algebraic Equations

    %Solve For C and lam

    %Plots of Data

    plot (t,T1,t,T2,t,T3,t,T4,t,T5,T,T6);
    grid on
    title('Temperature Simulation');
    xlabel('Time in seconds');
    ylabel('Temperature (degC)')
    Function file:

    Code (Text):
    function dydt = function3(t,y,p)

    %Mapping y to local state variables
    T1 = y(1);
    T2 = y(2);
    T3 = y(3);
    T4 = y(4);
    T5 = y(5);
    T6 = y(6);

    %Unpack parameters
    [Ti1, Ti2, Ti3, Ti4, Ti5, Ti6]= p{:};
    %lam1, lam2, lam3, lam4, lam5, lam6,

    %Solving the algebraic equations


    lam1 = -(log(T1)./(1.*log(C1.*Ti1)));
    lam2 = -(log(T2)./(1.*log(C2.*Ti2)));
    lam3 = -(log(T3)./(1.*log(C3.*Ti3)));
    lam4 = -(log(T4)./(1.*log(C4.*Ti4)));
    lam5 = -(log(T5)./(1.*log(C5.*Ti5)));
    lam6 = -(log(T6)./(1.*log(C6.*Ti6)));

    %Evaluate Derivatives
    dT1dt =-lam1.*(T1-Ti1);
    dT2dt =-lam2.*(T2-Ti2);
    dT3dt =-lam3.*(T3-Ti3);
    dT4dt =-lam4.*(T4-Ti4);
    dT5dt =-lam5.*(T5-Ti5);
    dT6dt =-lam6.*(T6-Ti6);

    dydt = [dT1dt dT2dt dT3dt dT4dt dT5dt dT6dt]';
    The code is "working" but the graphs are completely wrong and we get this message:

    Warning: Imaginary parts of complex X and/or Y arguments ignored
    > In Script3 at 49
    Last edited: May 14, 2012
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted