trying to take FFT of a signal but not getting the correct result

2 次查看(过去 30 天)
t1=load('201710h1.lvm'); %test 1
t2=load('201710h2.lvm'); %test 2
Fs = 100000; % frequency sample
x = t1 (:,1); % time for test 1
sin = t1 (:,2); % test 1 sesnor 1
plot(sin)
title('Sensor1')

采纳的回答

Star Strider
Star Strider 2021-2-9
Perhaps calling the fft function would get you closer.
Example —
t{1}=load('201710h1.lvm'); %test 1
t{2}=load('201710h2.lvm'); %test 2
Fs = 100000; % frequency sample
for k = 1:numel(t)
L = numel(t{k});
Ts = 1/Fs;
Fn = Fs/2;
tv = linspace(0, L, L)*Ts;
FTt = fft(t{k})/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(tv, t{k})
grid
xlabel('Time (sec)')
ylabel('Signal (Units)')
title(sprintf('t_{%d} Time Domain',k))
figure
plot(Fv, abs(FTt(Iv))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Amplitude (Units)')
title(sprintf('t_{%d} Frequency Domain',k))
end
Note that I loaded your signals into cell arrays to make the analysis easier.
  4 个评论
zeshan chishti
zeshan chishti 2021-2-10
Thank you i appreicte your help with this code it dose not recgnoise t1 as a variable. will have to change it around for it to work.
Star Strider
Star Strider 2021-2-10
As always, my pleasure!
Change the first two lines back to:
t1 = load('201710h1.lvm'); %test 1
t2 = load('201710h2.lvm'); %test 2
and the rest should work. (I changed my code to match your updated code, and forgot to change the ‘t1’ and ‘t2’ variables back to what they were originally.)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Hypothesis Tests 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by