How do i combine 2 functions into 1 graph

1 次查看(过去 30 天)
FIRST FUNCTION: function dydt=passiveinoutwithnumberofpumps (Np, D, Ao, y, x, s, t) dydt = Np*(D*((Ao-y)/x)*s);
In another script is: Np =0: 10; 20 ;30 ;40 ;50 ;60 ;70 ;80 ;90 ;100; D = 0.5; Ao = 0.7; x= 0.5e-6; s= 6e-6;
for i=Np [t,y]= ode23(@(t,y)passiveinoutwithnumberofpumps(i, D, Ao, y, x, s),[0 100],0);
plot (t,y) xlabel ('antibiotic treatment time') ylabel ('internal antibiotic') title ('passivein-out') end
then I click plot and get the graph that I want.
SECOND FUNCTION: function T=ribosometarget (T,l,r,k)
% CK % 05/3/2018 % This functions calculates the ribosome targets by gentamicin
r=0.1; l=[0:10:100]; k=4.5E-3;
T=r+(l/k)
plot (l,T)
xlabel ('specific growth rate')
ylabel ('ribosomal target')
title ('ribosome target available for gentamicin at different specific growth rate')
How do I combine both function and plot them into 1 graph where S=(Np*(D*((Ao-y)/x)*s))/(r+(l/k))

回答(2 个)

Paul Shoemaker
Paul Shoemaker 2018-3-5
Take a look at the "hold" command. You can create your first plot as you have, then use "hold on" to tell Matlab that you'd like to add another data series to the axis. Then plot your second item, followed by "hold off"
Paul Shoemaker

Star Strider
Star Strider 2018-3-5
I am not certain what you want.
Try this:
passiveinoutwithnumberofpumps = @(Np, D, Ao, y, x, s, t) Np*(D*((Ao-y)/x)*s);
Np = 0 : 10 : 100;
D = 0.5;
Ao = 0.7;
x= 0.5e-6;
s= 6e-6;
tv = linspace(0, 100, 25);
for i = 1:numel(Np)
[t(:,i), y(:,i)]= ode23(@(t,y)passiveinoutwithnumberofpumps(Np(i), D, Ao, y, x, s),tv,0);
end
% CK
% 05/3/2018
% This functions calculates the ribosome targets by gentamicin
r = 0.1;
l = 0:10:100;
k = 4.5E-3;
T = r+(l/k);
S = (Np.*(D*((Ao-y)/x)*s))./(r+(l/k));
figure(1)
subplot(2,2,1)
plot (tv,y)
xlabel ('antibiotic treatment time')
ylabel ('internal antibiotic')
title ('passivein-out')
grid
subplot(2,2,3)
plot (l,T)
xlabel ('specific growth rate')
ylabel ('ribosomal target')
title ('ribosome target available for gentamicin at different specific growth rate')
grid
subplot(2,2,[2 4])
surf(l, tv, S+1E-4)
set(gca, 'ZScale','log')
view(-130, 15)
xlabel('L')
ylabel('T')
zlabel('S')
grid on
set(gcf, 'OuterPosition',[150 150 1100 550])
Experiment to get the result you want. (I am using R2017b, so this should work with all recent versions.)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by