MATLAB Answers

Function definitions are not permitted.... trying to make an FFT thing

1 view (last 30 days)
Tom
Tom on 26 Jan 2012
Function definitions are not permitted.... trying to make an FFT thing
I'm trying to get this working
close all
clear all
function[X,freq]=positiveFFT(x,Fs);
N=length(x);
k=0:N-1;
T=N/Fs;
freq=k/T;
X=fft(x)/N;
cutOff = ceil(N/2);
X = X(1/cutOff);
freq = freq(1:cutOff);
Any ideas?

  0 Comments

Sign in to comment.

Accepted Answer

Tom
Tom on 26 Jan 2012
I think it might be right. Just discovered that the function line has to be the top line of code otherwise it doesn't work.

  0 Comments

Sign in to comment.

More Answers (2)

the cyclist
the cyclist on 26 Jan 2012
I think instead of this
X = X(1/cutOff)
you meant this
X = X*(1/cutOff);

  0 Comments

Sign in to comment.


Walter Roberson
Walter Roberson on 26 Jan 2012
You should think of "clear all" as being like trying to reprogram the fuel injector computer on a car: if you don't have years and years of training, you probably should not even be considering doing it.

  0 Comments

Sign in to comment.

Sign in to answer this question.

Products