フィルターのクリア

How to delete empty rows in a cell array?

38 ビュー (過去 30 日間)
Haron Shaker
Haron Shaker 2021 年 2 月 25 日
コメント済み: Rik 2021 年 2 月 25 日
Hello guys,
I want to delete all rows in a cell array which are empty, respectively where it says 'missing value'. I tried several functions but did not get the desired result.
I attached a screenshot for you to get an idea.
Thanks in advance!
  2 件のコメント
Jan
Jan 2021 年 2 月 25 日
If would help if you provide some input data. "empty or 'missing value'" are two different things. It is not clear, which of them is required. Is it a cell string, string array or a cell matrix? Where does the screenshot come from? Is this Matlab?
It helps if you post what you have tried already and explain, why this does not satisfies your needs. This would reduce the chance to spend time for writing in an answer, what you have tried already.
Haron Shaker
Haron Shaker 2021 年 2 月 25 日
Hi Jan ,
thanks for your answer.
I am using Matlab. I got an cell array, saved as .xls. Opening this file I get a 7x1 cell array (see founded_medicine_folder.xls), where three of the rows are empty. That is, I want to get an 4x1 array, without the empty ones.
I wrote both, "empty or 'missing value'", because reading the file with readcell() fills the empty rows with '1x1 missing'.

サインインしてコメントする。

採用された回答

Jan
Jan 2021 年 2 月 25 日
empty = cellfun('isempty', C);
C(empty) = [];
  3 件のコメント
Haron Shaker
Haron Shaker 2021 年 2 月 25 日
Hi Rik,
This does not work.
Reading the .xls file with readcell, fills the empty rows with '1x1 missing' ( see screenshot). Any idea how I can delete them?
Rik
Rik 2021 年 2 月 25 日
This is so similar to Jan's answer that I'm going to post it as a comment:
C=readcell('founded_medicine_folder.xls');
empty = cellfun('isclass', C, 'missing');
C(empty) = [];
celldisp(C)
C{1} = https:/www.isip.piconepress.com/projects/tuh_eeg/downloads/tuh_eeg/v1.1.0/edf/01_tcp_ar/085/00008530/s001_2012_01_04/ C{2} = https:/www.isip.piconepress.com/projects/tuh_eeg/downloads/tuh_eeg_abnormal/v2.0.0/edf/train/normal/01_tcp_ar/085/00008530/s001_2012_01_04/ C{3} = https:/www.isip.piconepress.com/projects/tuh_eeg/downloads/tuh_eeg_artifact/v1.0.0/edf/01_tcp_ar/085/00008530/s001_2012_01_04/ C{4} = https:/www.isip.piconepress.com/projects/tuh_eeg/downloads/tuh_eeg/v1.2.0/edf/01_tcp_ar/146/00014654/s001_2016_07_19/

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by