Azzera filtri
Azzera filtri

save path

18 visualizzazioni (ultimi 30 giorni)
M G
M G il 26 Mag 2011
Commentato: AMBIKA P S il 6 Mag 2018
Hello,
I have a problem with saving files in different paths and I am very thankful for your help.
Suppose there is a fix path:
path = 'D:\folder_1\folder_2';
If I wanna save a data set in the same path I would write:
save(fullfile(path,'FILE_NAME.MAT'));
However, base upon each data set I need to save them in different subfolders of folder_2 such as dataset_1 in folder_2A, dataset_2 in folder_2B, etc. Note that the base PATH is always the same. How can I do that?
Thanks so much :)

Risposta accettata

Arnaud Miege
Arnaud Miege il 26 Mag 2011
Something like that should do:
base_path = 'D:\folder_1\folder_2';
% You can also use dir to get the list of the subfolders
subfolder{1} = 'folder_2A';
subfolder{2} = 'folder_2B'; % etc...
fname{1} = 'dataset_1.mat';
fname{2} = 'dataset_2.mat'; % etc...
for k = 1:length(subfolder)
save(fullfile(base_path,subfolder{k},fname{k}));
end
HTH,
Arnaud
  6 Commenti
Walter Roberson
Walter Roberson il 5 Mag 2018
save( fullfile( base_path, subfolder{s}, subsubfolder{ss}, 'output_1.mat'), 'YourVectorNameGoesHereAsAString');
AMBIKA P S
AMBIKA P S il 6 Mag 2018
Thank you !

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Search Path in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by