Plots combining to produce one single plot
5 次查看(过去 30 天)
显示 更早的评论
I am completing a MATLAB course as part of my PhD studies but I am having an issue that is leaving me completely flumaxed. Early on in the module I used the following code to produce a plot, which all worked fine.
v = @(S,K,Vmax) Vmax*S/(K + S);
v1 = @(S) v(S,0.1,10);
v2 = @(S) v(S,1,10);
v3 = @(S) v(S,10,10);
limits = [0 10];
fplot(v1,limits,'r')
hold on
fplot(v2,limits,'b')
fplot(v3,limits,'g')
axis([0 10 0 10])
ylabel('rate')
xlabel('[S]')
legend('K=0.1','K=1','K=10','Location','SouthEast')
Later on I used this next bit of code to produce a different plot
%1) Plot a rate curve with a Eo value of 4, a k2 value of 0.03, a k-1
%value of 0.003, and a k1 value of 0.01.
k2 = 0.03;
Eo = 4;
k1 = 0.01;
kminus1 = 0.003;
Vmax = k2*Eo
Km = (kminus1+k2)/k1
v = @(S) Vmax*S/(Km+S);
limits = [0 100];
fplot(v,limits)
xlabel('[S]')
ylabel('rate')
What is happening is that the two plots are combining, even if I seperate them out as different sections and run the latter as it's own seperate thing. However, I know my code works to produce the plot I want as when I copy it into the command window or a seperate live file it works fine. So clearly these two are interacting but I don't know how. I tried changing the v in the second set of code to a q and plot fplot(q,limits) but that made no difference.
Help me wider community, you are my only hope.
0 个评论
采纳的回答
Joseph Cheng
2020-2-16
编辑:Joseph Cheng
2020-2-16
What i see is that you have a hold on and you didn't turn it off or designate a new plotting window/figure. Such athat depending on the order of running these sections it'll probably plot within the same window. Good practice if you want a new plot is to use the function figure() to generate a new plotting window and work with axes and figure handles. the function figure can take in a figure handle or a number to designate the window number. figure(1) or figure(100) will open up a new figure with that window number assigned it.
below is a snippet of code to show what is happening as well as how to assign and designate figure and axes handles to designate where plots go.
%here showing the stacking of plots due to the "hold on"
figure(1) ; %open new figure
plot(randi(10,1,10))
hold on
%%doing other stuff here
plot(1:10,1:10)
legend('first plot','second plot')
%forcing plots into new figures, and pointing the plots into which
%figure/axes to plot into
hfig2 = figure(2); %generate handle for figure(2)
hax2 = axes(hfig2); %assign handle for axes in figure(2)
hfig3 = figure(3);
hax3 = axes(hfig3);
%put plot specifically into figure(2)
plot(hax2,randi(10,1,10))
%put plot specifically into figure(3)
plot(hax3,1:10,1:10)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Filter Analysis 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!