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

 Accepted Answer

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

5 Comments

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 .
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?
Nevermind, fixed it. Thanks so much guys!

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!