how to store values for a further operation

조회 수: 1 (최근 30일)
Anthony Koning
Anthony Koning 2023년 4월 26일
답변: Star Strider 2023년 4월 26일
As the title implies, I would like to know how to store the values of parts of one function for use in a further part. For example, if I have a signal of 100 samples (x) that I want filtered for only 0-60 hz, I would filter the signal bandpass(x [0 60]). Let's call this inpute filt_x Now, if I wanted to perform a function like FFT on samples 30-40, how would I go about performing an FFT on only those specific values instead of having to FFT the whole signal and manually locate them?

채택된 답변

Star Strider
Star Strider 2023년 4월 26일
Perhaps something like this —
x = randn(2000, 1);
Fs = 250;
L = numel(x);
t = linspace(0, L-1, L).'/Fs;
figure
plot(t, x)
grid
xlabel('Time')
ylabel('Amplitude')
filt_x = lowpass(x, 60, Fs);
filt_x3040 = filt_x(30:40); % Select Segment Of Signal
Fn = Fs/2;
Lx = numel(filt_x3040);
NFFT = 2^nextpow2(Lx);
FTfilt_x3040 = fft(filt_x3040 .* hann(Lx), NFFT)/Lx;
Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, abs(FTfilt_x3040(Iv))*2)
grid
xlabel('Frequency')
ylabel('Magnitude')
title('Fourier Transform Of ‘filt\_x’ (30:40)')
The bandpass call as originally stated is actually a lowpass call. The bandpass passband must be greater than 0 and less than the Nyquist frequency.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by