Creating Table from csv files.

13 Ansichten (letzte 30 Tage)
Raushan
Raushan am 25 Jul. 2022
Kommentiert: Chunru am 25 Jul. 2022
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

Akzeptierte Antwort

Chunru
Chunru am 25 Jul. 2022
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 Kommentare
Raushan
Raushan am 25 Jul. 2022
@Chunru How you got the plots. When I ran the same code I am not getting any plots.
Chunru
Chunru am 25 Jul. 2022
Use your own folder name where data files are stored:
Folder='C:\Users\user\Desktop\7-19-22'

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by