# How can i make my results occupy less space on my plot?

3 views (last 30 days)
Sedat Peker on 27 Jun 2020
Answered: KSSV on 27 Jun 2020
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

#### 1 Comment

KSSV on 27 Jun 2020

KSSV on 27 Jun 2020
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.