Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

About looping a matrix

4 visualizaciones (últimos 30 días)
Ming Ki Lee
Ming Ki Lee el 27 de En. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
L=45;
tmax=60;
U=0.8;
D=1.6;
Xs=8;
Cs=10;
Xflux=36;
dt=6.328125;
dx=4.5;
mx=L/dx;
B = zeros(mx,1);
C = zeros(mx,mx);
C1 = zeros(mx,mx);
C2 = zeros(mx,mx);
t = 0 : dx : L;
n = 0:length(t)-1;
nvalue = interp1( t, n, Xs, 'nearest');
nvalue1=nvalue;
B(nvalue1,1)=Xs;
C1(1,1)=1;
for k=2:mx-1
nvalue1=k+2;
C1(k,nvalue1-3) = -D*dt/(dx)^(2)-U*dt/(2*dx);
C1(k,nvalue1-2) = 2*D*dt/(dx^2)+1;
C1(k,nvalue1-1) = -D*dt/(dx)^(2)+U*dt/(2*dx);
end
C1(mx,mx-1) = (-U*dt)/dx;
C1(mx,mx) = (U*dt)/dx+1;
Z=inv(C1);
C=Z*B;
end
So I got the answer of C by inverse(C1)*B
but I want to loop the inverse matrix(C1) to multiply the new b every time. for example, I want to loop this for 50 times. How to write this???
  1 comentario
KSSV
KSSV el 27 de En. de 2017
Editada: KSSV el 27 de En. de 2017
Loop with respective to what? I guess it is Xs..

Respuestas (1)

adi kul
adi kul el 27 de En. de 2017
add a for loop. something similar to:
for i=1:50
C(i)=Z(i)*B(i)
.
.
.
end

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by