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

 Respuesta aceptada

Kye Taylor
Kye Taylor el 15 de Jun. de 2012
If C is a cell, delete rows j through k using
C(j:k,:) = []; % note use of parentheses and not braces to index

5 comentarios

Benjamin
Benjamin el 15 de Jun. de 2012
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,:)
Kye Taylor
Kye Taylor el 15 de Jun. de 2012
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)
Walter Roberson
Walter Roberson el 15 de Jun. de 2012
You can do the separate approach if you do them highest index order first. e:f then c:d then a:b .
Benjamin
Benjamin el 15 de Jun. de 2012
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 el 15 de Jun. de 2012
Nevermind, fixed it. Thanks so much guys!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.

Preguntada:

el 15 de Jun. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by