필터 지우기
필터 지우기

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

조회 수: 14 (최근 30일)
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?

채택된 답변

KSSV
KSSV 2022년 3월 24일
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
lil brain
lil brain 2022년 3월 24일
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 );

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by