Natsortfiles for overlaying plots

2 ビュー (過去 30 日間)
Manuella Juwita
Manuella Juwita 2020 年 6 月 30 日
コメント済み: Stephen23 2020 年 7 月 4 日
I want to ask, how to use natsortfiles to sort alphanumerically overlaying plots in one figure? I find it difficult to match one plot to another because they have different directories and filenames
This is my code
% E = folder cropped greyscale
X = 'C:\Users\Lenovo\Documents\new matlab\hasil cacah 2\croppedk';
S = dir(fullfile(X,'*.jpg'));
contents = natsortfiles({S.name});
% I = folder contour
Y = 'C:\Users\Lenovo\Documents\new matlab\hasil cacah 2\contourk';
L = dir(fullfile(Y,'*.jpg'));
isi = natsortfiles({L.name});
for k = 1:numel(contents)
for i =1:numel(isi)
E = imread(fullfile(X,contents{k}));
% Make a truecolor all-green image.
green = cat(3, zeros(size(E)), ones(size(E)), zeros(size(E)));
hold on
h = imshow(green);
hold off
I = imread(fullfile(Y,isi{i}));
% green image.
set(h, 'AlphaData', I)
% Use our influence map image as the AlphaData for the solid
path = 'C:\Users\Lenovo\Documents\new matlab\hasil cacah 2\croppedk\zPlot';
saveas(gcf,fullfile(path,['zPlot' int2str(k) '.jpg']));
end
end
I want to overlay plots from different folders, folder 1 has filenames such as "gs1", "gs2" ,"gs3" ,"gs4" and folder 2 : "ax1"," ax2", "ax3" ,"ax4" so that i can overlay "gs1" with "ax1" and save as "z1", "gs2" with "ax2" and save as "z2", and so on.
  3 件のコメント
Manuella Juwita
Manuella Juwita 2020 年 7 月 1 日
編集済み: Manuella Juwita 2020 年 7 月 1 日
Sorry about the confusion, yes I wanted to overlay plots from different folders, folder 1 has filenames such as "gs1", "gs2" ,"gs3" ,"gs4" and folder 2 : "ax1"," ax2", "ax3" ,"ax4" so that i can overlay "gs1" with "ax1" and save as "z1", "gs2" with "ax2" and save as "z2", and so on.
How can I achieve this? Thank you in advance, Stephen.
Stephen23
Stephen23 2020 年 7 月 4 日
The sunokest approach is probably just to generate the filenames using sprintf:

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by