필터 지우기
필터 지우기

Custom FFT Function generates "Insufficient Number of Outputs"

조회 수: 2 (최근 30일)
Artificial_Spark
Artificial_Spark 2017년 3월 8일
편집: Steven Lord 2017년 3월 15일
Can someone help me determine why l'm getting this message? My Custom FFT Code:
function [X, freq] = centeredFFT(x,Fs)
N = length(x);
if mod(N,2)==0
k = -N/2:N/2-1;
else
k = -(N-1)/2:(N-1)/2;
end
T = N/Fs;
freq = k/T;
X = fft(x)/N;
X = fftshift(X);
end
My Double sided Frequency Spectrum Plot Code:
fo = 2000;
fp = 10000;
Fs = 4000;
Ts = 1/Fs;
t = 0:Ts:1-Ts;
s = (10 + cos(2*pi*fo*t)).*(cos(2*pi*fp*t));
[SfreqDomain,frequencyRange] = centeredFFT(s,Fs);
centeredFFT = figure;
stem(frequencyRange,abs(SfreqDomain));
grid on;
axis(-5,5,0,5);
Thank you for the assistance. Edited for typo.
[SL: edited to apply code formatting]
  댓글 수: 2
David Goodmanson
David Goodmanson 2017년 3월 8일
Hi Derrick This looks a lot like a case of defining centeredFFT = (something), somewhere in your script. Them Matlab doesn't recognize it as a function anymore and you get that kind of error message. I don't know the intent of the statement
enteredFFT = figure;
and if it is a typo for
centeredFFT = figure;
I would not know the intent of that either. But if the latter statement or something like it got executed, your function dies.
Artificial_Spark
Artificial_Spark 2017년 3월 8일
Yes it was a typo. centeredFFT = figure is to plot the FFT signal.

댓글을 달려면 로그인하십시오.

답변 (1개)

Brandon Eidson
Brandon Eidson 2017년 3월 15일
Hey Derrick, the only error I immediately see in your code is with your use of the "axis" command; you left off the brackets.  That line should be as follows.
axis([-5,5,0,5]);  
However, I am not sure if there is a case where that would produce the error "insufficient number of outputs".  Making the above change allowed me to execute your provided code without error.  If after changing the call to "axis" you are still getting an error, please provide more information about your workflow.  
David did point out something helpful.  The command 
centeredFFT = figure;
will create the variable "centeredFFT" and store in it a function handle.    But "centeredFFT" is the name of your custom.  This type of naming convention is not recommended.

카테고리

Help CenterFile Exchange에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by