Read csv file and remove some strings

조회 수: 2 (최근 30일)
Giorgos Papakonstantinou
Giorgos Papakonstantinou 2013년 4월 19일
I have a csv file which has values like the following:
0.0,-3.3,,
0.0,-4.9,,
0.1,-5.1,,
0.1,-5.8,,
When I use the csvread command then the two commas are mixing up my matrix and instead of having a matrix 4 by 2 I get a matrix 4 by 4 because in each line the commas are replaced by zeros. So instead of getting a matrix
0.0 -3.3
0.0 -4.9
etc...
I get a matrix
0.0 -3.3 0 0
0.0 -4.9 0 0
How can I remove the two commas?

답변 (1개)

Thomas
Thomas 2013년 4월 19일
Thats easy - don't. Just truncate the matrix:
A = A(:,1:2)
e.g. extract all rows and columns 1-2.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by