Index exceeds matrix dimensions
Afficher commentaires plus anciens
Hi
i'm trying to run the program below, so i have a 5*5 matrix which is y and and i'm trying to calculate E=sigma_{i,k}y(i,k)*((v+0.5)^(i-1))*((j(j+1))^(k-1)) summing over i=1:5 & k=1:5 for specific v&j and keep doing this summation for different v=1:10 and j=1:150, there for i must have a E matrix with dimension 10*150, but with the code i mentioned below, i get an error saying "Index exceeds matrix dimensions"
i attached the matlab file.
thank you
clear
clear all;
y=[0 0.243930066 -2.50171E-07 -4.652E-14 9.585E-19; 481.774655 -0.001611082 4.4226E-10 0 0;
-2.1018112 4.69192E-06 7.026E-12 0 0; 0.0066384 -5.282E-09 0 0 0; -0.000020255 0 0 0 0]
n=nan(10,150);
E=0
for v=1:10
for j=1:150;
for i=1:5;
for k=1:5;
E(v,j,i,k)=E+y(i,k)*((v+0.5)^(i-1))*((j(j+1))^(k-1));
n=E;
end
end
end
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!