How can I put Tn(n+1) and Tn(n-1) values into diff equations?

조회 수: 1 (최근 30일)
Martin Pecha
Martin Pecha 2018년 5월 4일
편집: Martin Pecha 2018년 5월 4일
I need to calculate system of equations for transport of heat between the cells - total number of cells is Ncell=19. Problem is that every cell in calculation is taking heat from cell(n-1) and cell(n+1). How can I write it down if these values are basically not calculated before? Is it possible to write it as a matrix where I choose specific values for Tn+1 and Tn-1?
dTdt(3) and dTdt(3+ncell+1) are the edge cells where one part interacts with T of air dTdt(4:3+ncell) are the one I need to write correctly where ncell are the inner cells (Ncell-2)
%parameters
Tinp=T(1);
Tinn=T(2);
T1=T(3);
Tn=T(4:3+ncell);
TN=(3+ncell+1);
Toutp=(4+ncell+1:4+2*ncell)';
Toutn=(4+2*ncell+1:4+3*ncell)';
Ttp=(4+3*ncell+1);
Ttn=(4+3*ncell+2);
TSoutp=1/ncell*(+sum(Toutp));
TSoutn=1/ncell*(+sum(Toutn));
Tnplus1=[Tn(2:17);TN]; %This is how I tried to write it
Tnminus1=[T1;Tn(1:16)]; %This is how I tried to write it
cTV2=y(1);
cTV3=y(2);
cTV4=y(3);
cTV5=y(4);
cCV2n=y(5:4+Ncell);
cCV3p=y(4+Ncell+1:4+2*Ncell);
cCV3n=y(4+2*Ncell+1:4+3*Ncell);
cCV4p=y(4+3*Ncell+1:4+4*Ncell);
cCV4n=y(4+4*Ncell+1:4+5*Ncell);
cCV5p=y(4+5*Ncell+1:4+6*Ncell);
dTdt=zeros(4+3*ncell+4,1);
% mass tank balance
dTdt(1)=(rho*Cp*QS*(Ttinp-Tinp)+Up*Ncell*Ap*(Tair-Tinp)+Wpump)/(rho*Cp*Vp*Ncell);
dTdt(2)=(rho*Cp*QS*(Ttinn-Tinn)+Up*Ncell*Ap*(Tair-Tinn)+Wpump)/(rho*Cp*Vp*Ncell);
%mass cell balance
dTdt(3)=(rho*Cp*QC*(Tinp-T1)+rho*Cp*QC*(Tinn-T1)+Ux*Ax*(Tn(1)-T1)+Uend*Ax*(Tair-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ysis에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by