Delete row when one cell is empty

2 ビュー (過去 30 日間)
Pauli
Pauli 2019 年 5 月 6 日
コメント済み: Pauli 2019 年 5 月 6 日
Hi,
I'm trying to delete those rows in an array that contain one empty cell. I have only to columns.
Is there an easy way to do this? I tried using ismissing() with an if statement, but can't seem to get the right result.
Thank you!
  1 件のコメント
Jan
Jan 2019 年 5 月 6 日
Please post a meaningful example, your code and explain, what "can't seem to get the right result" explicitly means.

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

採用された回答

Jan
Jan 2019 年 5 月 6 日
編集済み: Jan 2019 年 5 月 6 日
Perhaps:
C = {'a', 'b'; ...
[], 'c'; ...
'd', 'q'}
m = any(cellfun('isempty', C), 2); % Any cell in row is empty
C(m, :) = []
You wrote "one empty cell". This might mean:
C = {'a', 'b'; ...
{}, 'c'; ...
[], 'q'}
And you want to remove the 2nd row only, because you mean really an empty cell, but not the empty matrix. Maybe you want to keep the row, if it contains 2 empty cell, oder at least one empty array. Please explain this exactly.
  3 件のコメント
Jan
Jan 2019 年 5 月 6 日
Do you mean:
probs(probs(:,2) < 0.5, :) = [];
% ^
Pauli
Pauli 2019 年 5 月 6 日
Just found the mistake too. Thank you!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by