MATLAB Answers

Remove single cell from matrix

8 ビュー (過去 30 日間)
Thallon Pitchure
Thallon Pitchure 2020 年 9 月 22 日 20:26
コメント済み: Thallon Pitchure 2020 年 9 月 22 日 20:51
Hello!
I was wonderif if it is possible to remove a single cell from a matrix without having to resize it or remove an entire row or column.
I am specifically trying to remove A(2,2) from a 3x3 matrix. I know this is possible in a cell array can the same be done with a normal matrix.
I was thinking the output of removing the cell would be NaN but I cannot seem to get it to work without getting an error.
>> b(2,2) = []
A null assignment can have only one non-colon index.
>> b{2,2} = []
Cell contents assignment to a non-cell array object.
> This was not a cell array format when I attempted this method.

  0 件のコメント

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

採用された回答

madhan ravi
madhan ravi 2020 年 9 月 22 日 20:45
編集済み: madhan ravi 2020 年 9 月 22 日 20:49
”Remove single cell from matrix“
b(2, 2) = nan; % since matrix cannot have holes replace it with nans

  1 件のコメント

Thallon Pitchure
Thallon Pitchure 2020 年 9 月 22 日 20:51
Thank you for your time and help!!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by