フィルターのクリア

Creating Table from csv files.

10 ビュー (過去 30 日間)
Raushan
Raushan 2022 年 7 月 25 日
コメント済み: Chunru 2022 年 7 月 25 日
I have 5 csv files in a folder. all these csv files have multiple column with names like x,y,u,v....
I want to plot all u (In this case total 5 u will be there from five csv file) values in Matlab.
I am able to read and extract the column that contain u value from these csv files but not able to store it in array so that i can plot them on the same axis.
Can you please help!
Any help will be appreciated!
my code is
Folder='C:\Users\user\Desktop\7-19-22'
mat = dir(fullfile(Folder, '*.csv'));
disp(mat)
for files_i = 1:length(mat)
disp(mat(files_i).name)
data = fullfile(Folder,mat(files_i).name);
ReadCSV(data,files_i);
end
arr [];
function s = ReadCSV(data,i)
opts = detectImportOptions(data)
opts.SelectedVariableNames = {'u'};
T = readtable(data,opts);
disp(T)
end

採用された回答

Chunru
Chunru 2022 年 7 月 25 日
Folder=pwd; %'C:\Users\user\Desktop\7-19-22'
mat = dir(fullfile(Folder, '*.csv'));
uall = [];
for files_i = 1:length(mat)
data = fullfile(Folder,mat(files_i).name);
x = readtable(data);
uall =[uall x.u];
end
plot(uall)
  3 件のコメント
Raushan
Raushan 2022 年 7 月 25 日
@Chunru How you got the plots. When I ran the same code I am not getting any plots.
Chunru
Chunru 2022 年 7 月 25 日
Use your own folder name where data files are stored:
Folder='C:\Users\user\Desktop\7-19-22'

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by