Combining chart for comparison got error
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
dpb
on 28 Mar 2021
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.
2 Comments
More Answers (0)
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!