Plots combining into one
Show older comments
Hello all,
I had an issue before in which my plots were combining due to an open hold on function. I am having this issue again but I do not know the solution. I have closed all of my open hold on functions and yet it is still happening. I have included the code below.
%Code 1
w = @(Y,K,k,n) k*Y^n/(K^n + Y^n)
v = @(Y,K,k,n) k*K^n/(K^n + Y^n);
limits = [0 5];
for i=1:5,
vt = @(Y) v(Y,1,10,2);
fplot(vt,limits,'color','r');
end
hold on
for j=1:5,
wt = @(Y) w(Y,1,10,2);
fplot(wt,limits,'color','g');
end
hold off
axis([0 5 0 10])
ylabel('dX/dt')
xlabel('Y')
legend('repressor', 'activator', 'Location', 'northeastoutside')
%Code 2
syms a b X(t) X0;
eqn = diff(X)== a - b*X;
cond = X(0) == X0;
X = dsolve(eqn,cond);
pretty(X)
syms t a b X0
mX = matlabFunction(X,'vars',[t a b X0]);
f1 = @(t) mX(t, 10, 1, 1);
f2 = @(t) mX(t, 50, 5, 1);
f3 = @(t) mX(t, 5, 1, 1);
f4 = @(t) mX(t, 1.2, 0.1, 1);
limits = [0 10];
hold on
fplot(f1, limits, 'k');
fplot(f2, limits, 'r');
fplot(f3, limits, 'b');
fplot(f4, limits, 'g');
hold off
axis([0 10 0 11])
ylabel('X')
xlabel('time')
legend('a=10, b=1', 'a=50, b=5', 'a=5, b=1', 'a=1.2, b=0.1', 'Location', 'SouthEast')
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!