Trying to plot frequency spectrum from set of samples.

Hi everyone. I have a set of samples (x(n)’s) in a table corresponding to a mysterious signal x(t). What I am trying to do is display the frequency spectrum of this set of samples with a certain resolution.

I am confused on how to actually plot this frequency spectrum when I am just given a table of values, an fs, and using a certain N value.

So for example, say I was given a set of samples like this:

0 1 2 3 4 5 6 7 8 9 0 1.25 0.57 -0.29 -0.78 -0.70 0.37 0.87 0.49 -0.18

How would I plot the frequency spectrum with say a resolution of 50 hz?

I went about it like this, (keep in mind this code pertains to a set of samples that is 1251 long, I created the above example for ease of use), however my graph doesn’t look right as the magnitudes shouldn’t go above 1 since the amplitudes never go above 1?

signal = xt;
N = length(signal);
fs = 25000; % 25000 samples per second
fnyquist = fs/2; %Nyquist frequency
plot(abs(fft(signal)))
xlabel('Frequency Spectrum)')
ylabel('Magnitude');
title('Double-sided Magnitude spectrum');
axis tight

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

So for example, say I was given a set of samples like this:’

‘0 1 2 3 4 5 6 7 8 9 0 1.25 0.57 -0.29 -0.78 -0.70 0.37 0.87 0.49 -0.18’

‘How would I plot the frequency spectrum with say a resolution of 50 hz?’

You would do it with the absolutely clear code between the first two figures in the documentation for the fft function.

This is essentially an exact copy of that code, other than its using your vector and sampling frequency:

x = [0 1 2 3 4 5 6 7 8 9 0 1.25 0.57 -0.29 -0.78 -0.70 0.37 0.87 0.49 -0.18];
Fs = 50;
Fn = Fs/2;

SEE COMPLETE ANSWER CLICK THE LINK

--

--

--

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Top Algorithms and Data Structures You Really Need To Know

Black Box Manifesto, V1.0

Do Covid-19 vaccines really flatten the curve?

Maintaining Data on the Curb with CurbLR: A New Open Standard

Three Key Differentiators for Business Analysis and Business Data Analytics

Want to know the Future? Go to SXSW.

A sitting man explains something to a small crowd

Reservoir Sampling for Efficient Stream Processing

4 Ways Governments Can Publish Open Data on Infrastructure Projects

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Technical Source

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

More from Medium

what does eigenvalues expres in the covariance matrix?

Artificial intelligence can identify heart disease from eye fundus scans (Digital Health)

Hyperparameter Optimization: This is Almost All You Need

Will powerful AIs tend to seek power?