Apply a customized function to cell array

8 ビュー (過去 30 日間)
Susan
Susan 2020 年 7 月 10 日
コメント済み: Susan 2020 年 7 月 10 日
Hello everyone,
I have a C = 10*200 cell array. Inside each cell I have an M*N matrix. There are some zero columns and rows in each matrix and I would like to remove all zero columns of each matrix. I'm using the following function to do that
function[X_without_zero_cols] = RemoveZeroColumnsInCSImatrix(X)
cols_with_all_zeros = all(X == 0);
X_without_zero_cols = X(:, ~cols_with_all_zeros);
end
then I would like to apply this function to each cell. How should I do that? The following code isn't working
X_without_zero_cols = cellfun(@(X) RemoveZeroColumnsInCSImatrix(X), C)
Any idea?
TIA!!!

採用された回答

Stephen23
Stephen23 2020 年 7 月 10 日
D = cellfun(@RemoveZeroColumnsInCSImatrix, C, 'UniformOutput',false);
  1 件のコメント
Susan
Susan 2020 年 7 月 10 日
Thank you SO MUCH!!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by