Combining chart for comparison got error

1 visualización (últimos 30 días)
Hai Nguyen
Hai Nguyen el 28 de Mzo. de 2021
Comentada: Hai Nguyen el 30 de Mzo. de 2021
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?

Respuesta aceptada

dpb
dpb el 28 de Mzo. de 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 comentarios
Hai Nguyen
Hai Nguyen el 29 de Mzo. de 2021
I tried the new lines below as instructed but still got error.
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')

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by