Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Jos
Posts:
1,268
Registered:
10/24/08


Re: Subscript indices must either be real positive integers or logicals
Posted:
Feb 11, 2013 6:29 AM


"Gokul" wrote in message <kfagbg$i42$1@newscl01ah.mathworks.com>... > Hello, > > I have written a matlab program on audio processing and im getting the error : Subscript indices must either be real positive integers or logicals. > > %Fourier Transform of Sound File > > %Load File > file = 'C:\Program Files\MATLAB\Work\tuning_fork_A4'; > [y,Fs,bits] = wavread(file); > > Nsamps = length(y); > t = (1/Fs)*(1:Nsamps); %Prepare time data for plot > > %Do Fourier Transform > y_fft = abs(fft(y)); %Retain Magnitude > y_fft = y_fft(1:Nsamps/2); %Discard Half of Points > f = Fs*(0:((Nsamps1)1))/Nsamps; %Prepare freq data for plot > > %Plot Sound File in Time Domain > figure > plot(t, y); > xlabel('Time (s)'); > ylabel('Amplitude'); > title('Tuning Fork A4 in Time Domain'); > > %Plot Sound File in Frequency Domain > figure > plot(f, y_fft); > xlim([0 1000]); > xlabel('Frequency (Hz)'); > ylabel('Amplitude') > title('Frequency Response of Tuning Fork A4'); > > and the output is: > > ??? Subscript indices must either be real positive integers or > logicals. > > Error in ==> audiofft at 11 > y_fft = abs(fft(y)); %Retain Magnitude > > > > even for other fft function error repeats, > kindly help
The command WHOS will show that you have a variable called fft in your workspace ... CLEAR it before you run the code
Better still: put the code in a function mfile
~ Jos



