Plot images with iterative names as subplots
2 次查看(过去 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 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!