how to implementing energy function?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283037/image.jpeg)
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
0 Commenti
Risposta accettata
Ameer Hamza
il 9 Apr 2020
Modificato: Ameer Hamza
il 9 Apr 2020
For loop is not needed. Use can use vectorized operation
Sum = sum(V.^2, 'all');
16 Commenti
Ameer Hamza
il 11 Apr 2020
Modificato: Ameer Hamza
il 11 Apr 2020
Please create a new question and paste the link in the comment below. I will try to help.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!