Index exceeds array bounds for nested for loop
古いコメントを表示
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
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!