Why am I getting: Error using sum - Invalid option. Option must be 'double', 'native', 'default', 'omitnan', or 'includenan'.

22 visualizaciones (últimos 30 días)
Hi,
I have this for loop:
n = numel(cell_of_doubles);
distances_1 = cell(1,n);
for dd = 1:n
distances_1{dd} = sqrt(sum(cell_of_doubles{dd}(:,1:3),1,1).^2);
end
Whenever I try to run it I get the error,
Error using sum
Invalid option. Option must be 'double', 'native', 'default', 'omitnan', or 'includenan'.
It isn't clear to me why that is since my cell of doubles array is a double.
Does anyone know how I can solve this?

Respuesta aceptada

KSSV
KSSV el 24 de Mzo. de 2022
Repalce this line:
distances_1{dd} = sqrt(sum(cell_of_doubles{dd}(:,1:3),1,1).^2);
with
distances_1{dd} = sqrt(sum(cell_of_doubles{dd}(:,1:3),1).^2);
  1 comentario
lil brain
lil brain el 24 de Mzo. de 2022
This only gives me a cell array where each cell contains three values as a vector like so:
distances_1{1}
ans =
418.29 834.61 402.12
but what I want to create is a list of differences where line 1 is subtracted from line 2 and line 2 is subtracted from line 3 and line 3 is subtracted from line 4 and so on.
This is my original function which I am trying to make into a for loop:
distances_1 = sqrt( dx.^2 + dy.^2 + dz.^2 );

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Descriptive Statistics 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