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
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 Center 및 File Exchange에서 Axes Appearance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!