Natsortfiles for overlaying plots

3 vues (au cours des 30 derniers jours)
Manuella Juwita
Manuella Juwita le 30 Juin 2020
Commenté : Stephen23 le 4 Juil 2020
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 commentaires
Manuella Juwita
Manuella Juwita le 1 Juil 2020
Modifié(e) : Manuella Juwita le 1 Juil 2020
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 le 4 Juil 2020
The sunokest approach is probably just to generate the filenames using sprintf:

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Printing and Saving dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by