How can I combine plots in same axes?

2 次查看(过去 30 天)
I want to combine all plots in same axes, I tried to use hold on and hold off but it didn't work. Can anybody help me? Here's a part of the code:
for i=1:it
if i<=3
figure('Color','w');
hold on; box on; grid on;
params.flag_plot = 0;
npts = 41;
ec_max_vec = ec_max + linspace(0,abs(ec_max),npts);
Mtotal = zeros(npts,1);
Ntotal = zeros(npts,1);
for pt=1:npts
ec_max = ec_max_vec(pt);
x = fminbnd(@(x) EquilibriumVerification(x,ec_max,params,d,fy,Es,ey,Ast,b,h,ft,Ec,ec0,k3,fc,ecu),0,h,options);
[Fs,Fcc,Fct,Mc,Ms] = ComputeForcesAndMoments(ec_max_vec(pt),x,params,d,fy,Es,ey,Ast,b,h,ft,Ec,ec0,k3,fc,ecu);
Mtotal(pt) = Mc + Ms;
if (sign(Mc)~=sign(Ms))
disp('Here')
pause
end
Ntotal(pt) = Fs + Fcc + Fct;
end
plot(abs(ec_max_vec),abs(Mtotal)/100,'-b','DisplayName','Bending Moment (kN.m)')
plot(abs(ec_max_vec),Ntotal,'--r','DisplayName','Error (kN)')
l1 = legend;
set(l1,'Location','Southeast')
xlim([0 abs(ec_max_vec(1))])
xlabel('\epsilon_c_m_a_x','FontName',params.font_name,'FontAngle','italic','FontSize',params.font_size)
end
end
  3 个评论
Walter Roberson
Walter Roberson 2022-5-6
xlim([0 abs(ec_max_vec(1))])
You will need to track the maximum abs() over all of the plots and xlim with that after the loops
Also you should probably
ylim auto
after all the loops

请先登录,再进行评论。

回答(0 个)

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by