Combining chart for comparison got error
조회 수: 1 (최근 30일)
이전 댓글 표시
I used the code below to combine two figures as attached for comparison. The charts are extracted from the long code attached by changing the input between C=0 and C=1.
The charts:
The comparion lines:
if true
fig = figure(6);
ax = axes(fig);
xlabel('\xi');
ylabel(' \lambda(\xi,\tau)');
title('Comparions for the case K=1');
h1 = openfig('C0K1.fig','reuse');
h2 = openfig('C1K1.fig','reuse');
copyobj(h1.Children.Children,ax);
copyobj(h2.Children.Children,ax);
close(h1);
close(h2);
savefig('K1compare');
end
hold on
legend('C=0','C=1','location', 'northeast')
Error showed:
Error using copyobj
Too many input arguments.
Error in K1compare (line 9)
copyobj(h1.Children.Children,ax);
How to fix please?
댓글 수: 0
채택된 답변
dpb
2021년 3월 28일
h1.Children.Children returns a comma-separated list--
>> h1.Children.Children
ans =
0×0 empty GraphicsPlaceholder array.
ans =
2×1 Line array:
Line ( \lambda_u = 16.0623)
Line ( Classical P3D)
>>
You can let the empty placeholder be passed by
opyobj([h1.Children.Children,ax]);
copyobj([h2.Children.Children,ax]);
More robust would be to use findobj to only return and copy the lines.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!