Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc;
- clear;
- //coeficientes
- i=0;
- TD = 10;
- TE = 40;
- TINI = 25;
- L=1;
- alpha = 40;
- celulas = 5;
- dt = 0.1;
- dx = L/celulas;
- S = (alpha*dt)/(dx*dx);
- B=0.5;
- Tnova(1) = TE;
- Tnova(celulas) = TD;
- Tvelha(1)= TE;
- Tvelha(celulas)= TD;
- t=0
- tmax=400;
- totalit=0;
- tolerancia=0.000000001;
- for i=2:i<celulas
- Tnova(i)=TINI;
- Tvelha(i)=TINI;
- end;
- while(t<tmax)
- for totalit=0:totalit<=1000
- for i=2:i<celulas
- Taux = (S*B*(Tnova(i-1)+Tnova(i+1))+s(1-B)(Tvelha(i+1)+Tvelha(i-1)+Tvelha(i)+2*S*(1-B)*Tvelha(i)))/(1+2*S*B);
- erro=max(erro,ABS(Taux-Tnova(i));
- Tnova(i) = Taux;}
- end;
- if (erro<tolerancia) then
- break;
- end;
- totalit=totalit+1;
- end;
- t=t+1;
- end;
- for i=1:i<=celulas
- disp(Tnova(i));
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement