Multiply cell by cell

8 ビュー (過去 30 日間)
Tesla
Tesla 2021 年 9 月 17 日
コメント済み: Tesla 2021 年 9 月 17 日
I trying to muliply cell by cell.
Every cell has dimension 1001x1 and inside every cell I have 67x335 double.
So I want to multiply one by one. I tried with :
s=C_inside2.^2;
but I got this error:
Operator '.^' is not supported for operands of type 'cell'.

採用された回答

Jan
Jan 2021 年 9 月 17 日
編集済み: Jan 2021 年 9 月 17 日
Use a loop:
for k = 1:numel(C_inside2)
C_inside2{k} = C_inside2{k} .^ 2;
end
This is faster than cellfun:
C_inside2 = cellfun(@(x) x.^2, C_inside2, 'uniformoutput', false);
  1 件のコメント
Tesla
Tesla 2021 年 9 月 17 日
Thank you, it works!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by