Azzera filtri
Azzera filtri

Accessing Path names for reading Excel and saving .mat files in same folder

3 visualizzazioni (ultimi 30 giorni)
Hi,
I have Excel data files in a number of folders under the MATLAB folder (all on the MATLAB path). To speed up analysis, I would like to only read the Excel file once, and then save the variables in a .mat file *in the same folder *as the original Excel file.
How do you get the actual path name for the Excel file without having to manually input it so it can be prepended to the .mat file name?
Thanks
Doug

Risposta accettata

Walter Roberson
Walter Roberson il 23 Ott 2012
Together with:
idx = find(TheFilename == '.', 1, 'last');
NewFilename = TheFilename;
NewFilename(idx:end) = '.mat';

Più risposte (1)

Douglas Anderson
Douglas Anderson il 23 Ott 2012
Thanks, Walter.
I guess I wasn't really clear about what I was looking for. I was wondering if there is something like "which" for Excel files, which would give the pathname of an existing file (in an existing directory), rather than inputting the path directly. This is on a Windows computer, so perhaps it's not as straightforward.
OH!!!!!! I just found that which DOES work for that! Then the rest of it is appropriate, using the find to parse it. Great!
Doug

Categorie

Scopri di più su Data Import from MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by