I wanted to import csv files in a specific folder and wanted to plot graphs of them from the data of secound column and third column in the file can you please help me

1 view (last 30 days)
raks
raks on 26 May 2022
Answered: KSSV on 26 May 2022
directory = 'D:\APDL\Cylinder\CSV Files\';
files=dir(fullfile(directory,'*.csv'));
N = length(files) ;
for i = 1:N
T = readtable(files(i).name,'data') ;
x=T(:,1);
y=T(:,2);
plot(x,y);
xlabel('X coordinates');
ylabel('Y coordinates');
title('files[i]');
end

Answers (1)

KSSV
KSSV on 26 May 2022
thepath = 'D:\APDL\Cylinder\CSV Files\';
files = dir([thepath,'\*.csv'])
N = length(files) ;
for i = 1:N
file = fullfile(files(i).folder,files(i).name) ;
T = readtable(files(i).name,'data') ;
figure(i)
x=T.(2);
y=T.(3);
plot(x,y);
xlabel('X coordinates');
ylabel('Y coordinates');
title(files(i).name);
end

Tags

Community Treasure Hunt

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

Start Hunting!