Display multiple imagesc's in separate figure windows

20 Ansichten (letzte 30 Tage)
Samuel Brewton
Samuel Brewton am 20 Feb. 2021
Beantwortet: Mario Malic am 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.

Akzeptierte Antwort

Mario Malic
Mario Malic am 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.

Weitere Antworten (0)

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by