Natsortfiles for overlaying plots
2 views (last 30 days)
Show older comments
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 Comments
Stephen23
on 4 Jul 2020
The sunokest approach is probably just to generate the filenames using sprintf:
Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!