syms Temp_w Temp_g Temp_col%defining constant
m_w = 15; % mass of water in Kg
m_g = 5; % mass of glass cover in Kg
m_col = 6; % mass of collecter in Kg
c_w = 4179.6; % specific heat of water
c_g = 800; % specific heat of glass
c_col = 2000; % specific heat of collecter
a_w = 0.05; % absorbtivity of water
a_g = 0.08; % absorbtivity of glass
a_col = 0.9; % absorbtivity of collecter
Temp_a = 300; % ambient temerature in Kelvin
G_max = 630; % maximum irradiation of sun
G = 1:10;for time = 1:10 G(time) = (G_max/2)*(sin((pi*time)/12));endG_avg = mean(G); % avg of solar irradiation during a day
% belove are term use in ODE equation
q_ev = 16.273 * 0.884 * (((Temp_w - Temp_g + (((11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13))))*(Temp_w))/(268900 - 11.6834 - (3816.44/(Temp_w-46.13)))))^(1/3))) * (11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13)))) * (11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13))));q_cw = 0.884 * (((Temp_w - Temp_g + (((11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13))))*(Temp_w))/(268900 - 11.6834 - (3816.44/(Temp_w-46.13)))))^(1/3))) * (11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13)))) * (Temp_w - Temp_g);q_rw = 5.67 * (10^(-8)) * 0.96 * ((Temp_w^4) - (Temp_g^4));q_ca = 6.4 * (Temp_g - Temp_a);q_ra = 5.67 * (10^(-8)) * 0.93 * ((Temp_g^4) - (Temp_a^4));q_w = 1000 * (Temp_col - Temp_w);q_ins = (0.026 * (Temp_col - Temp_a))/0.01;ag_G = a_g*G_avg;aw_G = a_w*G_avg;acol_G = a_col*G_avg;% ODE equation(1) = q_ev + q_cw + q_rw + ag_G - q_ra - q_ca == m_g*c_g* (dTemp_g/dt)
syms Temp_g(t)ode_1 = m_g*c_g*diff(Temp_g,t) == 16.273 * 0.884 * (((Temp_w - Temp_g + (((11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13))))*(Temp_w))/(268900 - 11.6834 - (3816.44/(Temp_w-46.13)))))^(1/3))) * (11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13)))) * (11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13)))) + 0.884 * (((Temp_w - Temp_g + (((11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13))))*(Temp_w))/(268900 - 11.6834 - (3816.44/(Temp_w-46.13)))))^(1/3))) * (11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13)))) * (Temp_w - Temp_g) + 5.67 * (10^(-8)) * 0.96 * ((Temp_w^4) - (Temp_g^4)) + (a_g*G_avg) - 6.4 * (Temp_g - Temp_a) - 5.67 * (10^(-8)) * 0.93 * ((Temp_g^4) - (Temp_a^4));Temp_g_sol(t) = dsolve(ode_1)% ODE equation(2) = -q_ev - q_cw - q_rw + aw_G + q_w == m_w*c_w* (dTemp_w/dt)
syms Temp_w(t)ode_2 = m_w*c_w*diff(Temp_w,t) == -(16.273 * 0.884 * (((Temp_w - Temp_g + (((11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13))))*(Temp_w))/(268900 - 11.6834 - (3816.44/(Temp_w-46.13)))))^(1/3))) * (11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13)))) * (11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13))))) - (0.884 * (((Temp_w - Temp_g + (((11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13))))*(Temp_w))/(268900 - 11.6834 - (3816.44/(Temp_w-46.13)))))^(1/3))) * (11.6834 - (3816.44/(Temp_w-46.13)) - (11.6834 - (3816.44/(Temp_g-46.13)))) * (Temp_w - Temp_g)) - (5.67 * (10^(-8)) * 0.96 * ((Temp_w^4) - (Temp_g^4))) + (a_w*G_avg) + (1000 * (Temp_col - Temp_w));Temp_w_sol(t) = dsolve(ode_2)% ODE equation(3) = acol_G - q_w - q_ins == m_col*c_col* (dTemp_col/dt)
syms Temp_col(t)ode_3 = m_col*c_col*diff(Temp_col,t) == (a_col*G_avg) - (1000 * (Temp_col - Temp_w)) - ((0.026 * (Temp_col - Temp_a))/0.01);Temp_col_sol(t) = dsolve(ode_3)
MATLAB: I am trying to solve ODE having more than 1 dependent variable. but I am not able to solve it with dsolve function. please help me to find correct function to solve ODE.This is an mechanical engineering equation so it is bit complicated and lengthy
dsolveMATLABmatlab coderMATLAB Online Serverodeode113ode23ode45
Best Answer