How can I combine plots in same axes?

2 visualizaciones (últimos 30 días)
Ana Carolina da Silva Pacheco
Ana Carolina da Silva Pacheco el 6 de Mayo de 2022
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 comentarios
Walter Roberson
Walter Roberson el 6 de Mayo de 2022
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
Ana Carolina da Silva Pacheco
Ana Carolina da Silva Pacheco el 6 de Mayo de 2022
Thank you so much, it worked.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Axes Appearance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by