fft Invalid expression in plot

조회 수: 1 (최근 30일)
Alia Hicks
Alia Hicks 2020년 7월 28일
답변: Alia Hicks 2020년 7월 28일
I'm recieving error "Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters." at the second from last line "plot(t,f,); %amp vs time"
dt = .001;
t = 0:dt:1;
f = data_output;
%%Compute the Fast Fourier Transform FFT
n = length(t);
fhat = fft(f,n); % Compute the fast Fourier transform
PSD = fhat.*conj(fhat)/n; % Power spectrum (power per freq)
freq = 1/(dt*n)*(0:n); % Create x-axis of frequencies in Hz
L = 1:floor(n/2); % Only plot the first half of freqs
%%Use the PSD to filter out noise
indices = PSD>100; % Find all freqs with large power
PSDclean = PSD.*indices; % Zero out all others
fhat = indices.*fhat; % Zero out small Fourier coeffs. in Y
ffilt = ifft(fhat); % Inverse FFT for filtered time signal
%%PLOTS
plot(t,f,); %amp vs time
plot(f,fft); % mag vs freq

채택된 답변

madhan ravi
madhan ravi 2020년 7월 28일

추가 답변 (1개)

Alia Hicks
Alia Hicks 2020년 7월 28일
Thanks for your answer Madhan Ravi. I've rewritten it, " plot(t, f), hold on
plot (f, fft);" Now I get the error,
"Error using plot
Vectors must be the same length.
Error in Julytwentyseventh (line 21)
plot(t, f), hold on"

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by