how to store values for a further operation
2 次查看(过去 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?
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!