フィルターのクリア

Reading many csv files and Plot

3 ビュー (過去 30 日間)
Hormesis
Hormesis 2017 年 9 月 21 日
コメント済み: Walter Roberson 2017 年 9 月 21 日
Hey, I think my question is classic but i am beginner and i cant get it until now. I want to read many csv files where each one contains two columns and a header ( the header ist not important) . Later i want to plot it and analyse it. hier is my code but i get this error message: 'Reference to non-existent field 'names'.' hier is my code:
path = 'myPath';
liste = dir(path);
files = {liste.names};
for k=1:numel(files)
fileID = fopen(fullfile(path,files{k}),'r');
daten{k} = textscan(fid,'%s');
fclose(fileID);
end
can someone help me?
Thank you

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 9 月 21 日
You had a minor typing mistake.
I also changed the name of the variable path as that is an important MATLAB internal variable.
projectdir = 'myPath';
liste = dir( fullfile(projectdir, '*.csv') );
files = {liste.name};
for k=1:numel(files)
fileID = fopen( fullfile(projectdir, files{k}),'r');
daten{k} = textscan(fid,'%s');
fclose(fileID);
end
  2 件のコメント
Hormesis
Hormesis 2017 年 9 月 21 日
thank you Walter but i get the same Problem for this adjusted code:
projectdir= 'D:\myValues';
liste = dir( fullfile(projectdir, '*.csv') );
files = {liste.names};
for k=1:numel(files)
% einlesen der Dateien
fileID = fopen( fullfile(projectdir, files{k}),'r');
daten{k} = textscan(fid,'%s');
fclose(fileID);
end
Walter Roberson
Walter Roberson 2017 年 9 月 21 日
Why are you using liste.names ? The field name is what I used, name not names. See https://www.mathworks.com/help/matlab/ref/dir.html#outputarg_listing

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

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by