knuth
knuth

Reputation: 11

subplots in MatLab

I use a loop to generate different images that I then collect into a figure with each image as a subplot. I do this for several different iterations of the loop and set the background for each figure to be a certain color, say red as in the example below - which works fine except the last iteration still has a default gray color - how do I change that?

set(gcf,'Color','red')

Also... kind of related: within the loop how do you make a figure that is separate from the others? So for example

figure(i)
subplot etc.

How would I then make a totally different figure for each iteration if that makes sense?

Upvotes: 1

Views: 681

Answers (1)

Jonas
Jonas

Reputation: 74940

To create a new figure, you do not have to call figure with an argument. fh = figure; creates a new figure and captures the figure handle in the variable fh. You can then use fh to change the figure's properties, e.g. set(fh,'Color','red'). Of course, if there's no need to only set the figure's color at the end of the loop, you can set it when you create the figure, like so: fh = figure('color','red');.

Upvotes: 1

Related Questions