Display multiple imagesc's in separate figure windows

25 ビュー (過去 30 日間)
Samuel Brewton
Samuel Brewton 2021 年 2 月 20 日
回答済み: Mario Malic 2021 年 2 月 20 日
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)
My hope is that I can have each image open in separate windows.


Mario Malic
Mario Malic 2021 年 2 月 20 日
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 件)


Find more on Graphics Object Properties in Help Center and File Exchange





Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by