Yotam
Yotam

Reputation: 10695

matlab printing splitted plot to file

I'm creating a code to do data analysis that will run on a server. The code is supposed to spit a pdf file with 3 plots on it.

I have created a code that generates the plot

fig = figure;
for i = 1:3
  %do some calculation to find, X, Y and fit
  subplot(3,1,i)
  scatter(X,Y)
  hold on
  plot(X,fit)
end

print (fig, '-dpdf','fig.pdf')

X, Y, and fit are calculated/imported parameters. The output of this code is a pdf document with only the last plot on it (missing the first two).

How can I print all three of them to file?

Upvotes: 2

Views: 111

Answers (1)

titus
titus

Reputation: 450

I tried your code on my CPU (X,Y and fit were generated randomly) and it works fine, so the bug may come from the interaction of this snip of code with you "%do some calculations block"

I would suggest to add a "hold off" command before the end of the for loop ...

gus

Upvotes: 1

Related Questions