フィルターのクリア

I want to make the figure hanger look like the attached picture. The code is shown below.

3 ビュー (過去 30 日間)
T K
T K 2021 年 8 月 25 日
コメント済み: Rena Berman 2022 年 8 月 23 日
clc
L=3;% L=y fare away the the plate (boundary layer)
T=2;%Final time
maxk=500;%Number of time steps
dt=T/maxk;
n=50;%Number of space steps
dy=L/n;
diff=0.25;
b=diff*dt/(dy*dy);
%b=0.1;
%initial condition of velocity
for i=1:n+1
y(i)=(i-1)*dy;
u(1,1)=0;
end
%Boundary condition
for k=1:maxk+1
u(1,k)=1;
u(n+1,k)=0;
end
for k=1:maxk %time loop
for i=2:n %space loop
u(i,k+1) =u(i,k)+b*(u(i-1,k)+u(i+1,k)-2.*u(i,k));
end
end
%Ploting
figure(1)
%plot(y,u(:,1),'-',y,u(:,100),'-',y,u(:,300),'-',y,u(:,600),'-')
plot(y,u(:,50),'-',y,u(:,100),'-',y,u(:,200),'-',y,u(:,250),'-')
%legend('dt=50','dt=100','dt=200','dt=250')
title('Velocity in the boundary layer')
xlabel('y')
ylabel('velocity')
  2 件のコメント
T K
T K 2021 年 8 月 26 日
編集済み: T K 2021 年 8 月 26 日
 The picture is attached
Rena Berman
Rena Berman 2022 年 8 月 23 日
(Answers Dev) Restored edit

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 8 月 26 日
Instead of using plot() use surf(), with 'edgecolor', 'none', and with 'alphadata' set to a constant repeated the same size as u, and with AlphaDataMapping 'none' and with 'FaceAlpha', 'flat'
  3 件のコメント
Walter Roberson
Walter Roberson 2021 年 8 月 26 日
surf(x, y, u, 'edgecolor', 'none', 'AlphaDataMapping', 'none', 'FaceAlpha', 'flat', 'Alpha', 0.8 * ones(size(u)));
hold on
This would be in a loop in which you changed whatever it is you need to change, creating a new u matrix each time.
T K
T K 2021 年 8 月 26 日
Please doctor walter Roberson, when writing the attached code, an error appeared:
Undefined function or variable 'x'.
Error in Untitled (line 24)
surf(x(i), y(i), u(i), 'edgecolor', 'none', 'AlphaDataMapping', 'none', 'FaceAlpha', 'flat', 'Alpha', 0.8 * ones(size(u(i))));
code attached
clc
L=3;
T=2;
maxk=500;
dt=T/maxk;
n=50;%Number of space steps
dy=L/n;
diff=0.25;
b=diff*dt/(dy*dy);
%initial condition
for i=1:n+1
y(i)=(i-1)*dy;
u(1,1)=0;
end
%Boundary condition
for k=1:maxk+1
u(1,k)=1;
u(n+1,k)=0;
end
for k=1:maxk %time loop
for i=2:n %space loop
u(i,k+1) =u(i,k)+b*(u(i-1,k)+u(i+1,k)-2.*u(i,k));
surf(x(i), y(i), u(i), 'edgecolor', 'none', 'AlphaDataMapping', 'none', 'FaceAlpha', 'flat', 'Alpha', 0.8 * ones(size(u(i))));
hold on
end
end
%Ploting
figure(1)
plot(y,u(:,50),'-',y,u(:,100),'-',y,u(:,200),'-',y,u(:,250),'-')
legend('dt=50','dt=100','dt=200','dt=250')
title('Velocity in the boundary layer')
xlabel('y')
ylabel('velocity')

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by