Multiply cell by cell

1 visualización (últimos 30 días)
Tesla
Tesla el 17 de Sept. de 2021
Comentada: Tesla el 17 de Sept. de 2021
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'.

Respuesta aceptada

Jan
Jan el 17 de Sept. de 2021
Editada: Jan el 17 de Sept. de 2021
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 comentario
Tesla
Tesla el 17 de Sept. de 2021
Thank you, it works!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by