Index exceeds array bounds for nested for loop
Afficher commentaires plus anciens
As I am running the loop separately for a limited values, it is given the correct result. The moment i add a nested for loop, it shows an error stating "Index Exceeds array bounds". Data file is attached along with this.
For the reference, i am attaching the code:
datafile= importdata('abc.txt') %input data file
x=20; %total number of elements to be considered in one slot
g= ones(x,1)/x; %unit sample response
i=x; %initial value
len=193; %total number of elements in data file
z=datafile.^3; %cube of data present in file
s=zeros(x,1) %initialise sum as 0
for i = x:len-1 %Loop to calculate sum
for j = i-x+1:i
r(j) = z(j)* g(j);
s(i) = s(i)+r(j);
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!