There is a mistake while using condtional and for loop condtion.i got the value zero only. but i want values and here, A is subdiagonal, B is diagonal and C is superdiagonal.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
xmax=1; ymax=20; dx=0.05; dy=0.25; dt=0.02;m=xmax/dx; n=ymax/dy; UOLD=zeros(m,n); VOLD=zeros(m,n);
for j=1:n
if i==2:m
C(i)=V(i,j)*dt/4*dy-dt/2*(dy)^2;
elseif i==1:m-1
A(i)=-V(i,j)*dt/4*dy-dt/2*(dy)^2;
elseif i==1:m
B(i)=1+U(i,j)*dt/2*dx+dt/(dy)^2;
end
end
2 comentarios
Torsten
el 23 de Dic. de 2022
So many errors...
I suggest you first pass the 2 hours MATLAB online tutorial for free before you continue:
Sulaymon Eshkabilov
el 24 de Dic. de 2022
Study the [while ... end] loop: https://www.mathworks.com/help/matlab/ref/while.html
Respuestas (1)
Atsushi Ueno
el 24 de Dic. de 2022
The inside of the if sentence is never be executed even if i takes any value.
i = 3;
if i == 2:5
disp('true');
end
i == 2:5
if [0 1 0 0]
disp('true');
else
disp('false');
end
if [1 1 1 1]
disp('true');
else
disp('false');
end
1 comentario
Atsushi Ueno
el 24 de Dic. de 2022
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!