필터 지우기
필터 지우기

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 (최근 30일)
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
Torsten
Torsten 2022년 12월 23일
So many errors...
I suggest you first pass the 2 hours MATLAB online tutorial for free before you continue:

댓글을 달려면 로그인하십시오.

답변 (1개)

Atsushi Ueno
Atsushi Ueno 2022년 12월 24일
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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by