faster reading using csvread question

조회 수: 2 (최근 30일)
colors
colors 2017년 5월 22일
답변: Matthew Eicholtz 2017년 5월 22일
I have a csv file that looks like the below
_TYPE_ _NAME_ a b c d date
CRR a 1 0.778220822 0.711397234 0.29490149 4/30/2017
CRR b 1 0.778220822 0.711397234 0.29490149 4/30/2017
CRR d 1 0.778220822 0.711397234 0.29490149 4/30/2017
CRR e 1 0.778220822 0.711397234 0.29490149 4/30/2017
I would like to store the numeric values column a-d as a matrix the date column as a separte variable in form of a vector the name column as a separate variable in form of a vector.
the number of numeric columns can differ in this above example it is only 4 , but you can have varying number of columns, the last column is always the date and the first two columns are always type and name
I have been using xlsread for this but was wondering if there is a faster way using csvread or some other function
many thanks for your help

답변 (1개)

Matthew Eicholtz
Matthew Eicholtz 2017년 5월 22일
Have you tried readtable? I haven't run any timing diagnostics to see which is faster, but that could be another option for you to try.
Here's an example function call:
T = readtable(filename,'Delimiter',',','ReadVariableNames',true);

카테고리

Help CenterFile Exchange에서 Oceanography and Hydrology에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by