plotting 2 figures in same for loop

15 visualizaciones (últimos 30 días)
Somnath
Somnath el 25 de Oct. de 2025
Comentada: Somnath el 25 de Oct. de 2025
Dear Comunity Members
Im relatively new to matlab. i wanted to plot two figurs simultaneously in for loop meanng and in these two figres i wanted to add multiple data sets when if condistion is valid. i have following code but these giving me diffent figure for each set. i want two figurs whn particular condition satisfied.
for i=1:6
if rem(i,2)==0
figure
hold on
s1=scatter(x,i*[6 3 9 10 7],100,"filled");hold off
else
figure
hold on
s2= scatter(x,i*[6 3 9 10 7],100,"filled");hold off
end
end
can some one plese help me to figure this out
Best regards
Somnath

Respuesta aceptada

Torsten
Torsten el 25 de Oct. de 2025
Editada: Torsten el 25 de Oct. de 2025
figure
hax1=axes;
hold(hax1,'on')
figure
hax2=axes;
hold(hax2,'on')
x=1:5;
for i=1:6
if rem(i,2)==0
scatter(hax1,x,i*[6 3 9 10 7],100,"filled");
else
scatter(hax2,x,i*[6 3 9 10 7],100,"filled");
end
end
hold(hax1,'off')
hold(hax2,'off')
  1 comentario
Somnath
Somnath el 25 de Oct. de 2025
Thank you very much it is working as expected

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Annotations 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