how to implementing energy function?

6 vues (au cours des 30 derniers jours)
Mehul Jain
Mehul Jain le 9 Avr 2020
Commenté : Mehul Jain le 12 Avr 2020
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

Réponse acceptée

Ameer Hamza
Ameer Hamza le 9 Avr 2020
Modifié(e) : Ameer Hamza le 9 Avr 2020
For loop is not needed. Use can use vectorized operation
Sum = sum(V.^2, 'all');
  16 commentaires
Ameer Hamza
Ameer Hamza le 11 Avr 2020
Modifié(e) : Ameer Hamza le 11 Avr 2020
Please create a new question and paste the link in the comment below. I will try to help.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by