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!