How can i make my results occupy less space on my plot?
1 回表示 (過去 30 日間)
古いコメントを表示
In my code, my results on my plot occupies a lot of space. So i want to plot results skipping few steps and also add time label on each figure just as the picture below.
Here is my code. Can you help me please?
n = 101; % Number of grids
dy = 1.0 / (n-1);
Re = 100; % Reynolds Number we define
phi_new = zeros(1,n); % Storing velocity values for each point n==>which is y axis. And we defined no slip boundary condition here
phi_new(n) = 1; % Second boundary condition
phi_old = phi_new;
dt = 5.0e-3; % Maximum dt in order to keep the system stabile. Because we use Explicit Method
gamma = (dt/(Re*dy*dy)); % Calculated gamma value after discretization, for keeping equations simple
t = 50; % Time term
% Explicit FTCS
for i=1:dt:t+1
plot(phi_new(1,:),1:n)
for j=2:n-1
phi_new(j) = phi_old(j) + gamma * (phi_old(j+1) - 2*phi_old(j) + phi_old(j-1)); % Discretized Equation
end
phi_old = phi_new;
hold on
end
採用された回答
KSSV
2020 年 6 月 27 日
n = 101; % Number of grids
dy = 1.0 / (n-1);
Re = 100; % Reynolds Number we define
phi_new = zeros(1,n); % Storing velocity values for each point n==>which is y axis. And we defined no slip boundary condition here
phi_new(n) = 1; % Second boundary condition
phi_old = phi_new;
dt = 5.0e-3; % Maximum dt in order to keep the system stabile. Because we use Explicit Method
gamma = (dt/(Re*dy*dy)); % Calculated gamma value after discretization, for keeping equations simple
t = 50; % Time term
% Explicit FTCS
i = 1:dt:t+1 ;
m = length(i) ;
iwant = zeros(m,n) ;
for i=1:m
iwant(i,:) = phi_new(1,:) ;
for j=2:n-1
phi_new(j) = phi_old(j) + gamma * (phi_old(j+1) - 2*phi_old(j) + phi_old(j-1)); % Discretized Equation
end
phi_old = phi_new;
end
Now the required data is saved into a matrix iwant. You can skip the rows and plot.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Gamma Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!