필터 지우기
필터 지우기

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 CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by