필터 지우기
필터 지우기

How can I combine plots in same axes?

조회 수: 1 (최근 30일)
Ana Carolina da Silva Pacheco
Ana Carolina da Silva Pacheco 2022년 5월 6일
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
Ana Carolina da Silva Pacheco
Ana Carolina da Silva Pacheco 2022년 5월 6일
Thank you so much, it worked.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by