フィルターのクリア

how to implementing energy function?

2 ビュー (過去 30 日間)
Mehul Jain
Mehul Jain 2020 年 4 月 9 日
コメント済み: Mehul Jain 2020 年 4 月 12 日
i want to implement this above energy function and i tried this following code, but i am getting 'Index exceeds matrix dimensions.' error. How can do this?
e=[];
V=WT.dec{1,1};
for x=1:17
for y=1:19
for z=1:18
e = e + (V(x,y,z))^2;
end
end
end

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 9 日
編集済み: Ameer Hamza 2020 年 4 月 9 日
For loop is not needed. Use can use vectorized operation
Sum = sum(V.^2, 'all');
  16 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 4 月 11 日
編集済み: Ameer Hamza 2020 年 4 月 11 日
Please create a new question and paste the link in the comment below. I will try to help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by