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)
end
My hope is that I can have each image open in separate windows.

채택된 답변

Mario Malic
Mario Malic 2021년 2월 20일
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개)

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by