I have a code where I need to show 3 plots on the same figure, but one is so small, that it looks like a line running along the bottom.
Is there a way to have 2 scales in one window so that I can plot my 2 similar plots on a scale , and my smaller plot with a second scale?
Code below if you want to see for yourself, the blue one needs to be scaled in the first window.
thanks all,
Alex
close all
clear all
clc
L1 = 0.001; % lambda 1
L2 = 0.5; % lambda 2
N0 = 1E12; % initial number of atoms of first nuclide
O0 = 0; % initial number of atoms of second nuclide
P0 = 0; % initial number of atoms of third nuclide
Ts = [3600/923, 3600/900, 3600/897]; % time steps
for a = 1:length(Ts)
T = 0:Ts(a):3600; % array of times for calculation
N = zeros(length(T),1); % initializing space for first nuclide
O = zeros(length(T),1); % initializing space for second nuclide
P = zeros(length(T),1); % initializing space for third nuclide
N(1) = N0; % setting initial count in place 1
O(1) = O0;
P(1) = P0;
for i = 1:length(T)-1
N(i+1) = N(i) - L1*N(i)*Ts(a);
O(i+1) = O(i) + L1*N(i)*Ts(a) - L2*O(i)*Ts(a);
P(i+1) = P(i) + L2*O(i)*Ts(a);
end
figure % will generate new figure for each time step used
hold on % plotting all in the same figure window
plot(T,N,'r') % plot first decay in red
plot(T,O,'b') % plot second decay in blue
plot(T,P,'g') % plot third decay in green
if a == 1
title(char('Behavior of the Radioactive Decay Chain N1 -> N2 -> N3',...
'Using Euler Method with Time Step 3.9 sec.'));
elseif a == 2
title(char('Behavior of the Radioactive Decay Chain N1 -> N2 -> N3',...
'Using Euler Method with Time Step 4 sec.'));
elseif a == 3
title(char('Behavior of the Radioactive Decay Chain N1 -> N2 -> N3',...
'Using Euler Method with Time Step 4.01 sec.'));
else
title('Behavior of the Radioactive Decay Chain N1 -> N2 -> N3 Using Euler Method')
end
xlabel('Time (s)')
ylabel('Number of Atoms')
legend('N1', 'N2', 'N3')
end
Is there a way to have 2 scales in one window so that I can plot my 2 similar plots on a scale , and my smaller plot with a second scale?
Code below if you want to see for yourself, the blue one needs to be scaled in the first window.
thanks all,
Alex
close all
clear all
clc
L1 = 0.001; % lambda 1
L2 = 0.5; % lambda 2
N0 = 1E12; % initial number of atoms of first nuclide
O0 = 0; % initial number of atoms of second nuclide
P0 = 0; % initial number of atoms of third nuclide
Ts = [3600/923, 3600/900, 3600/897]; % time steps
for a = 1:length(Ts)
T = 0:Ts(a):3600; % array of times for calculation
N = zeros(length(T),1); % initializing space for first nuclide
O = zeros(length(T),1); % initializing space for second nuclide
P = zeros(length(T),1); % initializing space for third nuclide
N(1) = N0; % setting initial count in place 1
O(1) = O0;
P(1) = P0;
for i = 1:length(T)-1
N(i+1) = N(i) - L1*N(i)*Ts(a);
O(i+1) = O(i) + L1*N(i)*Ts(a) - L2*O(i)*Ts(a);
P(i+1) = P(i) + L2*O(i)*Ts(a);
end
figure % will generate new figure for each time step used
hold on % plotting all in the same figure window
plot(T,N,'r') % plot first decay in red
plot(T,O,'b') % plot second decay in blue
plot(T,P,'g') % plot third decay in green
if a == 1
title(char('Behavior of the Radioactive Decay Chain N1 -> N2 -> N3',...
'Using Euler Method with Time Step 3.9 sec.'));
elseif a == 2
title(char('Behavior of the Radioactive Decay Chain N1 -> N2 -> N3',...
'Using Euler Method with Time Step 4 sec.'));
elseif a == 3
title(char('Behavior of the Radioactive Decay Chain N1 -> N2 -> N3',...
'Using Euler Method with Time Step 4.01 sec.'));
else
title('Behavior of the Radioactive Decay Chain N1 -> N2 -> N3 Using Euler Method')
end
xlabel('Time (s)')
ylabel('Number of Atoms')
legend('N1', 'N2', 'N3')
end