Multiply cell by cell

조회 수: 1 (최근 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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by