how to store values for a further operation

1 次查看(过去 30 天)
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