Create Folder and Keep files

조회 수: 7 (최근 30일)
Robert Roy
Robert Roy 2017년 5월 23일
댓글: Naqvi 2019년 9월 17일
Hi there, I am trying to save matlab images and excel files into a specific folder on my hardrive. This requires to make a new folder using mkdir however everytime I run the code and I change the base file to get a new set of results , all the old set of results are replaced by the new files, basically there duplicated with the same base name
%%Saving Images to Folder
% DESCRIPTIVE TEXT
for k=1:8;
mkdir H:\7thMarch
folder='H:\7thMarch';
baseFileName=sprintf('Fig%d.fig',k);
fullFileName=fullfile(folder,baseFileName);
savefig(F(k),fullFileName);
end
%%Saving to Excel
% DESCRIPTIVE TEXT
baseFileName=sprintf('Eq2.1.xlsx',k);
fullFileName=fullfile(folder,baseFileName);
sheet=1;
xlRange='A1';
xlswrite(fullFileName,HAB.',sheet,xlRange);
  댓글 수: 1
Walter Roberson
Walter Roberson 2017년 5월 23일
Are you asking how to look in the folder to determine which Fig*.fig files already exist, so as to use the next available numbering instead of always using Fig1.fig through Fig8.fig ?
If so, have you considered using a date/time component to the name so that the names do not clash?

댓글을 달려면 로그인하십시오.

답변 (1개)

kousar majeed
kousar majeed 2019년 6월 14일
HOW TO CREATE A FOLDER AND SAVE IT IN MATLAB need code
  댓글 수: 1
Naqvi
Naqvi 2019년 9월 17일
mkdir 'newfolder'

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by