How can we combine the two figures?

조회 수: 2 (최근 30일)
JooYoung Jeon
JooYoung Jeon 2021년 11월 25일
댓글: Star Strider 2021년 11월 26일
When you execute the code below, two plots are drawn.
However, I want to combine these two plots and make them into one plot. What should I do?
figure(1)
plot(x,ys,'m')
hold on
%%%%%%%%adding vertical lines%%%%%%%%
n = 20; %%%%%%%% number of lines %%%%%%%
x_ref = 7800;
xx=linspace(x(1)+100,x(end)-100,n);
yy = interp1(x,ys,xx);
for ci=1:n
plot([x_ref+(ci-n/2)*50 xx(ci)],[0 yy(ci)],'r');
pause(0.05);
end
hf = figure()
ha = axes()
hp1 = plot(hip_y, hip_z, 'o')
hold(ha,'on')
hp2 = plot(knee_y, knee_z, 'o')
hp3 = plot(ankle_y, ankle_z, 'o')
hp4 = plot(tarsal_y, tarsal_z, 'o')

답변 (1개)

Star Strider
Star Strider 2021년 11월 25일
When you execute the code below, two plots are drawn.’
No, not without knowing what the variables are.
However the problem is that the beginning of the (posted) code creates figure(1) then after the loop, another figure appears and is assigned to ‘hf’, so everything subsequent to it is plotted in the second figure.
Use hold and eliminate the second figure call and it should work as desired.
.
  댓글 수: 2
JooYoung Jeon
JooYoung Jeon 2021년 11월 26일
Thank you. I'll try and leave a comment.
Star Strider
Star Strider 2021년 11월 26일
My pleasure!
.

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

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by