want to read 38 csv files only first and second column?

조회 수: 7 (최근 30일)
muhammad choudhry
muhammad choudhry 2020년 10월 27일
댓글: KSSV 2020년 10월 27일
Hi,
I want to read first and second coloumn of the 48 .csv files then plot the data from them coloumns. Once data plotted seaparately then want to apply the circle algoritham to it which will give me the estimated radius of the circle in list or array then I want to plot them against time?
Can you guys help I do not know how to read column 1 and 2 of them 48 files?
  댓글 수: 3
muhammad choudhry
muhammad choudhry 2020년 10월 27일
편집: muhammad choudhry 2020년 10월 27일
file names are like contours0.90....till contours0.137......I have attached the few files only wants to read first 2 columns which represents x and y values of the plot ...z -axis values are not needed which is 3rd column.
muhammad choudhry
muhammad choudhry 2020년 10월 27일
and this a algoritham code which will then applied to find the radius of the circle I can do manually one by one but that's not a goal.

댓글을 달려면 로그인하십시오.

채택된 답변

Sudhakar Shinde
Sudhakar Shinde 2020년 10월 27일
편집: Sudhakar Shinde 2020년 10월 27일
csvFile = dir("*.csv") ;
N = length(csvFile) ;
for i = 1:N
data = readtable(csvFile(i).name) ;
iwant = data.Points_0;
iwant1 = data.Points_1;
% do what you want
end
  댓글 수: 2
muhammad choudhry
muhammad choudhry 2020년 10월 27일
what does this line representing ? data = readtable(csvFiles(i).name) as I am getting error in this line does anything req. to change here ?
Unrecognized function or variable 'csvFiles'.
Error in SimuCircle (line 7)
data = readtable(csvFiles(i).name) ;
Sudhakar Shinde
Sudhakar Shinde 2020년 10월 27일
편집: Sudhakar Shinde 2020년 10월 27일
it was typing error.
use csvFile instead of csvFiles. Corrected in above code lines.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

KSSV
KSSV 2020년 10월 27일
편집: KSSV 2020년 10월 27일
csvFiles = dir("*.csv") ;
N = length(csvFiles) ;
for i = 1:N
data = csvread(csvFiles(i).name) ; % also read about xlsread
iwant = data(:,1:2) ; % read first two columns
% do what you want
end
  댓글 수: 4
Sudhakar Shinde
Sudhakar Shinde 2020년 10월 27일
Name of csv file contains multiple dots , example: contours0.90.csv and looks like csvread producess error for this.
Use readtable or readmatrix instead.
KSSV
KSSV 2020년 10월 27일
There is a typo error..edited the code.....

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by