I have a different number of .mat files in several folders, which I would like to import, plot data und save it in the same folder as a pdf file.
Here an example with two folders:
C:\Users\I2d1_4_1_1\
y3.mat
y4.mat
y5.mat
C:\Users\I5d1_4_1_1\
y3.mat
y4.mat
y5.mat
y6.mat
My two questions are:
- How do i save it in the same folder without changing the directory.
- How to adapt the code that i dont need to change the for loop i=3:5 for the first folder and i=3:6 for the second folder.
DataPath ='C:\Users\';for i=3:60 for input=[2 5 8]for delay=[4 8 12];for delayinput=[1 4 8]; load([DataPath 'I%dd1_%d_1_%d\y' num2str(i) '.mat',input,delay,delayinput]) figure(1), plotregression(x, y); SaveName = sprintf('NN_%d_1_%d',i,delay);saveas(figure(1),fullfile(DataPath 'I%dd1_%d_1_%d', SaveName),'pdf')endendendend
Thanks for your help.
Best Answer