Opening all .txt files in a folder and importing/saving columns of data separately which may be called upon and graphed.

155 ビュー (過去 30 日間)
Attached you will find code of the things that I have tried. I am having issues with the importing of the data. When I read from a single individual .txt file my code works but I am having issues implementing a way to do this with all .txt files in a folder. I have run impedance spectrums for neural cuffs and need to find a way to graph each working electrode in each cuff, in each medium, with three trials. Any help would be so appreciated.

採用された回答

KSSV
KSSV 2018 年 7 月 18 日
files = dir('*.txt') ; % you are in the folder of files
N = length(files) ;
% loop for each file
for i = 1:N
thisfile = files(i).name ;
% do what you want
end
  8 件のコメント
Stephen23
Stephen23 2018 年 7 月 30 日
編集済み: Stephen23 2018 年 7 月 30 日
"Will dir work with 5 columns of data?"
What does that mean? dir accepts an single character vector input, so it is not clear what you mean when you write that it "work with 5 columns of data": what columns? What data? What does "work with" actually mean in terms of MATLAB?
Your code has a bug, you need to use D, not S, like this:
D = 'C:\Users\Sarah\Desktop\Sarah_2018\DI_Trial_1';
S = dir(fullfile(D,'*.txt'));
Sarah Brianne
Sarah Brianne 2018 年 7 月 30 日
編集済み: Stephen23 2018 年 7 月 30 日
I saw that and already tried changing that and tried different folders

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

その他の回答 (1 件)

Sarah Brianne
Sarah Brianne 2018 年 8 月 13 日
So I have information from impedance spectrums. I have 5 columns of data Z,Z',Z'',Freq,Phase. I changed the error you said I have but when I try to use this code my S is a 0x1 with no data. The iterations of i is zero. My N is also equal to zero. There are text files in all the different folders I have tried opening.

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by