Thomas algorithm - tridiagonal matrix
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Cesar Cardenas
il 1 Mar 2023
Commentato: Cesar Cardenas
il 2 Mar 2023
Is there any other way to code and solve the tridiagonal matrix? the idea would be to try to get the plot shown. Matlab beginner, so, no sure how to do it. Any help will be greatly appreciated. Thanks
clear
cm=1/100;
delta = 1*cm;
nu=1e-6;
Uinf=1;
H=2*delta;
y=linspace(0,H,40);
u=Uinf*erf(3*y/delta);
dy=mean(diff(y));
dx=100*dy;
Q=nu*dx/Uinf/dy^2;
a=-Q;
c=-Q;
b=1+2*Q;
N=length(y)-2;
M = diag(b*ones(1,N)) + diag(c*ones(1,N-1),1) + diag(a*ones(1,N-1),-1);
%Constant Ue
Ue = @(x) Uinf;
u = u(2:end-1);
x=0;
uall=[0,u,Ue(x)];
0 Commenti
Risposta accettata
Torsten
il 2 Mar 2023
Modificato: Torsten
il 2 Mar 2023
clear
cm=1/100;
delta = 1*cm;
nu=1e-6;
Uinf=1;
H=2*delta;
y=linspace(0,H,40);
u=Uinf*erf(3*y/delta);
dy=mean(diff(y));
dx=100*dy;
Q=nu*dx/Uinf/dy^2;
a=-Q;
c=-Q;
b=1+2*Q;
N = length(y);
M = diag(b*ones(1,N)) + diag(c*ones(1,N-1),1) + diag(a*ones(1,N-1),-1);
M(1,:) = [1,zeros(1,N-1)];
M(end,:) = [zeros(1,N-1),1];
%Constant Ue
Ue = @(x) Uinf;
u = u(2:end-1);
x=0;
uall=[0,u,Ue(x)];
sol = M\uall.';
plot(y,sol)
grid on
5 Commenti
Torsten
il 2 Mar 2023
You can assign values to certain elements in a matrix by using a loop. But if the above line to define M is correct, it's elegant, isn't it ? Why do you want to define it differently ?
Più risposte (0)
Vedere anche
Categorie
Scopri di più su GPU Computing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!