Hello,
I want to go to a certain folder by using cd and fullfile to have the path. But I have an error when I do my third line of code (below) telling: Error using cd Argument must contain a string. Could you help me please ?? I really don't understand my mistake since fullfile('E:\Dropbox (LMD)\Noémie\SpO2 Project\AltiTrainer\', Foldernames(i)) for i=1 gives me the right path !
Foldernames = cellstr(char('John', 'Peter', 'Jack')
for i= 1: length(Foldernames)
cd(fullfile('E:\Dropbox (LMD)\Noémie\SpO2 Project\AltiTrainer\', Foldernames(i)))
Filenames(i) = dir('*_modif.csv');
A = readcsv(Filenames(i));
end
Thank you very much for wour answer !
NoNo

 採用された回答

Titus Edelhofer
Titus Edelhofer 2015 年 9 月 24 日

0 投票

Hi,
since Foldernames is a cell array you need to use {} for access to elements. Replace
cd(fullfile('E:\Dropbox (LMD)\Noémie\SpO2 Project\AltiTrainer\', Foldernames(i)))
by
cd(fullfile('E:\Dropbox (LMD)\Noémie\SpO2 Project\AltiTrainer\', Foldernames{i}))
Foldernames{i} is a string, Foldernames(i) is a 1x1 cell array. And fullfile wants to receive a string, not a 1x1 cell ...
Titus

3 件のコメント

Titus Edelhofer
Titus Edelhofer 2015 年 9 月 24 日
BTW, I assume your first line is due to some simplification. Otherwise simply write
Foldernames = {'John', 'Peter', 'Jack'};
NoNo
NoNo 2015 年 9 月 24 日
Thank you very much !! and yes, I simplified the Fordernames ;)
Titus Edelhofer
Titus Edelhofer 2015 年 9 月 25 日
Your welcome. You might mark the question then as answered, if you like.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Filename Construction についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by