running it an error occurs as follows:??? Subscript indices must either be real positive integers or logicals. Error in ==> hanningwindow at 15 y(f)=20*log(abs(b));

clear all;
clc;
N=input('enter the value of N=')
n = 0:N-1;
b = 0.5*(1 - cos(2*pi*n/(N-1)));
plot(n,b)
xlabel('time samples')
ylabel('amplitude')
figure
f=0:N-1;
fmax=max(f);
m=f/fmax;
y(f)=20*log(abs(b));
plot(m,y)
xlabel('normalized frequency')
ylabel('magnitude')

 Accepted Answer

The error is in this line
y(f)=20*log(abs(b));
It should be
y=20*log(abs(b));
Also avoid using clear all, use just clear

More Answers (0)

Community Treasure Hunt

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

Start Hunting!