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

5 ビュー (過去 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 Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by