Plot images with iterative names as subplots
조회 수: 4 (최근 30일)
이전 댓글 표시
I have several images that I have read in as A1 to A43. For instance,
A1= imread('False_Color/20181007.png');
A2= imread('False_Color/20181015.png');
A3= imread('False_Color/20181023.png');
Then I am trying to use a loop to print all 43 images since the names are so similar. I think I am close, but I can't figure out how to remove the quotes so that I can plot imagesc(A3) instead of imagesc('A3') which of course does not work. Please let me know if there is another function I should be using instead of sprintf. Thank you!
This is what I am doing:
for i=1:length(dates_over)
f1=figure(1)
subplot(5,9,i)
imagesc(sprintf('%s%d','A',i)) %I want to loop through so it does imagesc(A1) then imagesc(A2) then imagesc(A3) etc
title(sprintf('%s',dates_over(i)),'fontsize',12) %this works
end
댓글 수: 0
채택된 답변
Matt J
2020년 11월 9일
편집: Matt J
2020년 11월 9일
First you need to fix the way you read in the images. They should go into the elements of a cell array likse so,
A{1}= imread('False_Color/20181007.png');
A{2}= imread('False_Color/20181015.png');
A{3}= imread('False_Color/20181023.png');
...
A{43}=...
and then you would do,
for i=1:length(dates_over)
f1=figure(1)
subplot(5,9,i)
imagesc(A{i}) %I want to loop through so it does imagesc(A1) then imagesc(A2) then imagesc(A3) etc
title(sprintf('%s',dates_over(i)),'fontsize',12) %this works
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!