Clear Filters
Clear Filters

i want to find out cheybsev type 1 filter average of graph FOR ORDER UPTO 50 . but one error is coming

1 view (last 30 days)
g=1;
for n=0:50 %for initialising order
LBC=0;
Ln=0;
fc=50;
f=0:1:300;
x=f/fc;
e=0.5;
if n==0
T=0;
end
if n==1
T=x;
end
a=T.*T;
smr=1./(1+0.25.*a);
for i=2:n % for writing chebysev polynomial
T0=x;
T1=1;
T=(2.*x.*T1-T0);
T0=T1;
T1=T;
end
for fs=1:50 % less than cutoff frequency
if smr(1,fs)~=1
LBC=LBC+(1-smr(1,fs));
Ln=Ln+1;
else
end
LAB(1,g)=LBC/Ln;
g=g+1;
end
end
n=0:50;
plot(n,LAA)
ERROR:
Index in position 2 exceeds array bounds. Index must not exceed 1.
Error in c (line 35)
if smr(1,fs)~=1

Answers (1)

Sivapriya Srinivasan
Sivapriya Srinivasan on 31 Aug 2023
Hello
The error message you're seeing indicates that the index fs in the line if smr(1,fs)~=1 exceeds the array bounds. This means that the value of fs is greater than the size of the array smr. The array smr is defined inside the loop for n=0:50, and its size depends on the value of n.
To fix this issue, you need to ensure that the size of smr is large enough to accommodate the index fs. One possible solution is to initialize smr outside the loop for n=0:50 with a size that can accommodate the maximum value of fs.
Hope this helps!

Community Treasure Hunt

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

Start Hunting!