Deleting multiple cell rows after using uiimport

Is there a way to delete multiple rows from an imported csv file after using uiimport()? For example: rows 1-8, 917-932, 1841-1856... etc The reason for needing these rows deleted is that they give invalid numbers and mess up analysis and plotting.
Thanks

 채택된 답변

Kye Taylor
Kye Taylor 2012년 6월 15일

1 개 추천

If C is a cell, delete rows j through k using
C(j:k,:) = []; % note use of parentheses and not braces to index

댓글 수: 5

Benjamin
Benjamin 2012년 6월 15일
so would I do something like this?
data() is the variable nambe of the table so i assume i use that?
a = 1;
b = 8;
c = 917;
d = 932;
e = 1841;
f = 1856;
data(a:b,c:d,e:f) = [ ];
because this gives me the error: Matrix index is out of range for deletion.
or should
i do a separate one for each cell section being deleted, such as:
data(a:b,:)
data(c:d,:)
data(e:f,:)
The separate approach won't work since after removing the first set, the row indices shift. Instead, just slightly modify your first approach that was giving the error as follows:
a = 1;
b = 8;
c = 917;
d = 932;
e = 1841;
f = 1856;
data([a:b,c:d,e:f],:) = [];
(You need to include the square brackets, and the last command + colon inside parenthesis)
You can do the separate approach if you do them highest index order first. e:f then c:d then a:b .
Benjamin
Benjamin 2012년 6월 15일
Doing it all as one, didn't work correctly. it provided this error: A null assignment can have only one non-colon index.
But after followings Walter's idea it worked out. But it is only being applied to the plot which is great, but it is still showing those rows in my table. Is there a way to remove them from both?
Benjamin
Benjamin 2012년 6월 15일
Nevermind, fixed it. Thanks so much guys!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2012년 6월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by