Clear Filters
Clear Filters

How to find frequency contents in this signal below?

1 view (last 30 days)
  2 Comments
Abhishek Nayak
Abhishek Nayak on 20 Aug 2019
Edited: Abhishek Nayak on 20 Aug 2019
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.

Sign in to comment.

Answers (1)

Abhishek Nayak
Abhishek Nayak on 26 Aug 2019
Edited: Adam Danz on 26 Aug 2019
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

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!