Plot images with iterative names as subplots
1 回表示 (過去 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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!