Display multiple imagesc's in separate figure windows
20 views (last 30 days)
Show older comments
Samuel Brewton
on 20 Feb 2021
Answered: Mario Malic
on 20 Feb 2021
I am looking to use the imagesc command to display an image of a matrix. I'm looking to do this multiple times but each new iteration overrides the last.
Here is some sample code to get the idea.
for i=1:5 % Five iterations
matrix=eye(i); % Creates some matrix (identity for example)
imagesc(matrix); % Displays matrix as an image
% Image gets overridden (only 5x5 identity matrix displays at end)
end
My hope is that I can have each image open in separate windows.
0 Comments
Accepted Answer
Mario Malic
on 20 Feb 2021
Hello,
if you don't supply the axes handle to plot on, it will use gca axes to plot on. If there are no axes to plot on, gca will create new one.
ax(1) = axes(figure(1))
ax(2) = axes(figure(2))
% and so on
Replace your imagesc line with this one
imagesc(ax(i), matrix);
However, having 5 figures open is not the tidiest way to do it, consider using subplots.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!