How to find frequency contents in this signal below?

1 次查看(过去 30 天)
  2 个评论
Abhishek Nayak
Abhishek Nayak 2019-8-20
编辑:Abhishek Nayak 2019-8-20
Thanks for answering the question, but I was not able to get the adequate results by using fft. Can you please figure out the probem in the folowing code
The code I followed is shown below.
%% to obatin the datas in the figure
h = findobj(gca,'Type','line')
x=get(h,'Xdata') ;
y=get(h,'Ydata') ;
%% using fft to obtain the frequency contents in the signal
sam=x(end)/length(x); % sampling time
X=fft(y); % using fft
P2=abs(X/length(X)); % To normalize and obtain magnitude
P1=P2(1:1+(length(X)+1)/2); % To compute the single-sided spectrum P1
fre=(1/sam)*(0:(length(X)+1)/2); % To obtain the spread of freqency
figure(25)
plot(fre,P1) % To plot the frequency contents in the signal
It can be seen from the asked figure that the freqency contenets are in low freqency range but the obtained results are in very fast freqency range.

请先登录,再进行评论。

回答(1 个)

Abhishek Nayak
Abhishek Nayak 2019-8-26
编辑:Adam Danz 2019-8-26
I figured it out finaly,
there was a mistake in the code
%% to obatin the datas in the figure
h = findobj(gca,'Type','line')
x=get(h,'Xdata') ;
y=get(h,'Ydata') ;
%% using fft to obtain the frequency contents in the signal
sam=x(end)/length(x); % sampling time
X=fft(y); % using fft
P2=abs(X/length(X)); % To normalize and obtain magnitude
P1=P2(1:1+(length(X)+1)/2); % To compute the single-sided spectrum P1
fre=(1/sam)*(0:(length(X)+1)/2)/length(X); % To obtain the spread of freqency
figure(25)
plot(fre,P1) % To plot the frequency contents in the signal

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by