how to implementing energy function?

9 visualizaciones (últimos 30 días)
Mehul Jain
Mehul Jain el 9 de Abr. de 2020
Comentada: Mehul Jain el 12 de Abr. de 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

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by