MATLAB Answers

0

How do use gplot as subplots in a for loop?

Asked by Brandon Lieberthal on 22 Feb 2019
Latest activity Commented on by Brandon Lieberthal on 22 Feb 2019
Hello,
I'm am trying to produce a plot of 5 x 5 network graphs in a subplot formation. This is my Matlab code:
figure
hold on
for i = 1:25
[xdata,ydata,AdjMat] = makerandomnetwork();
subplot(5,5,i);
gplot(AdjMat,[xdata ydata],'k')
end
The problem is that all the other subplots are cleared whenever a new subplot is generated. Any advice?

  0 Comments

Sign in to comment.

1 Answer

Answer by Gani
on 22 Feb 2019
Edited by Gani
on 22 Feb 2019
 Accepted Answer

Put hold on inside the loop.
figure
for i = 1:25
[xdata,ydata,AdjMat] = makerandomnetwork();
subplot(5,5,i);
gplot(AdjMat,[xdata ydata],'k')
hold on
end

  1 Comment

Never mind, I figured it out. The makerandomnetwork() function I was using had a "close all" hidden in it. Thanks for your help.

Sign in to comment.