I have a folder which has a name as 1250, 1270, 1290, 1310, 1330, 1370, 1390 (first level)
and inside that each folder it has folder name pos1, pos2, pos3… (second level)
some of them has pos5 and some only have up to pos4
Now for each pos# folder, I want to do exactly same work.
SO I want to compute the code,Change folder name 1250\pos1Do workChange folder name 1250\pos2Do work (same)Change folder name 1250\pos3Do work (same)Change folder name 1270\pos1Do work (same)Change folder name 1270\pos2Do work (same)Change folder name 1290\pos1Do work (same)................
here is my code I have been working on.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for k=1250:20:1390 % first level folder name
shot_path= 'D:\DME_Run\';for i=1:5 %number of pos folder here just say 5 %second level
t= sprintf('%s%.4d\\pos%.1d\\',shot_path,k,i); files = dir([fullfile(shot_path, y) '*.mat']); load(files(1).name); x = zeros(768,768);%%%%%%%%%%%%%%%%%%%%work%%%%%%%%%%%%%%%%%%%
for j=1:500 %each folder has 500 image
load((['Process_shot_f',num2str(j),'.mat'])); % Load the files. Notice how "eval" is not needed.
x = x + Process_shot_fj; % x is the name of the variable.
end Mean_process_image = x./ length(files); % Average.
%%%%%%%%%%%%%%%%%%%%work%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%save%%%%%%%%%%%%%%%%%%%
y= sprintf('%s','Mean_process_image', int2str(i) ,'.mat'); savedir = sprintf('D:\\data\\Process shot\\%.4d\\pos%d',k,i); if i==1 mkdir(savedir); end save(fullfile(savedir, y), ['Mean_process_image_pos_i']); endend%%%%%%%%%%%%%%%%%%%%save%%%%%%%%%%%%%%%%%%%
clear;clc;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Best Answer