trying to find L2 norm using for loops. where am I doing wrong?
1 回表示 (過去 30 日間)
古いコメントを表示
clear all
clearvars
x = [1.21, -3.42, 10.01, -0.13, -5.11, -1.29, 3.87, 2.16, -3.21, 0.02]
n = length(x)
sumx = 0
for x = 1: n
sumx = sum + [x(n)^2]
end
L2 = sqrt(sumx)
0 件のコメント
採用された回答
KSSV
2017 年 10 月 16 日
x = [1.21, -3.42, 10.01, -0.13, -5.11, -1.29, 3.87, 2.16, -3.21, 0.02] ;
n = length(x) ;
sumx = 0 ;
for i = 1: n
sumx = sumx + x(i)^2 ;
end
L2 = sqrt(sumx)
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!