Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Subscript indices must either be real positive integers or logicals
Replies: 1   Last Post: Feb 11, 2013 6:29 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Jos

Posts: 1,266
Registered: 10/24/08
Re: Subscript indices must either be real positive integers or logicals
Posted: Feb 11, 2013 6:29 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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:((Nsamps-1)-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 m-file

~ Jos



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.