# 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.

4 views (last 30 days)
Gayathri on 23 Dec 2022
Commented: Atsushi Ueno on 24 Dec 2022
xmax=1; ymax=20; tmax=100; dx=0.05; dy=0.25; dt=0.2; t=0;m=xmax/dx; n=ymax/dy; n=ymax/dy; UWALL=0; UOLD=zeros(m,n);VWALL=0;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
T(:,j) = tridiag(A,B,C,D);
##### 2 CommentsShowHide 1 older comment
Sulaymon Eshkabilov on 24 Dec 2022

Atsushi Ueno on 24 Dec 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
ans = 1×4 logical array
0 1 0 0
if [0 1 0 0]
disp('true');
else
disp('false');
end
false
if [1 1 1 1]
disp('true');
else
disp('false');
end
true
##### 1 CommentShowHide None
Atsushi Ueno on 24 Dec 2022