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,:)
Kye Taylor
Kye Taylor 2012 年 6 月 15 日
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 2012 年 6 月 15 日
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 ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by