single plot, dft graph?

Hi folks just asking how you can a single point graph plotted, so that its x against y. the x plot should be 0:120, every 5 seconds. and y plot should be these values: 62,57,56,55,57,56,58,62,62,63,61,61,62,62,62,61,60,60,60,61,65,68,67,66,67 These values represent a reading every 5 seconds
in the format of the link below is what i'm trying to get.
https://www.google.co.uk/search?q=matlab+dft+graph&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjwoJnT77DLAhWCHxoKHQ6GArUQ_AUIBygB&biw=1920&bih=1033#imgrc=Npbkd6ifbaMW3M%3A
hope this makes sense

2 comentarios

Star Strider
Star Strider el 8 de Mzo. de 2016
See the R2015a documentation for fft. Pay special attention to the code between the top two figure images. Everything you need is there.
david  hanna
david hanna el 9 de Mzo. de 2016
Star Strider
i need an activation license to see the document you mention. I'm using matlab at my college,i.e. their computers, when i type license into the matlab prompt for the code i get: 347765 when i type this in for access onto the document,it doesnt allow me. any ideas? thanks

Iniciar sesión para comentar.

Respuestas (5)

Ilham Hardy
Ilham Hardy el 9 de Mzo. de 2016

1 voto

Perhaps this is what you want,
xdat = 0:5:120;
ydat = [62,57,56,55,57,56,58,62,62,63,61,61,62,62,62,61,60,60,60,61,65,68,67,66,67];
scatter(xdat,ydat,'filled')
set(gca,'xtick',0:5:120)
grid on

1 comentario

david  hanna
david hanna el 14 de Mzo. de 2016
llham Hardy
not exactly, but it does do the trick i suppose for my case, and just working through matlab. am having difficulty regarding doing a fourier transform or short-time fourier transform, on this signal. having problems relating to the tutorials compared to my own signal :(

Iniciar sesión para comentar.

Star Strider
Star Strider el 13 de Abr. de 2016

1 voto

This is how I would code it:
xdat = 0:5:120;
ydat = [62,57,56,55,57,56,58,62,62,63,61,61,62,62,62,61,60,60,60,61,65,68,67,66,67];
Ts = mean(diff(xdat)); % Sampling Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = length(ydat); % Signal Length (Obviously)
ft_y = fft(ydat)/L; % Fourier Transform (Normalised)
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
figure(1)
plot(Fv, 2*abs(ft_y(Iv)))
grid
xlabel('Frequency (Arbitrary Units)')
ylabel('Amplitude (Arbitrary Units)')
There’s a relatively high d-c offset. You can eliminate that by subtracting the mean of ‘ydat’ before you take the fft. This will make the other frequencies more apparent.

6 comentarios

davy hanna
davy hanna el 13 de Abr. de 2016
as in plot(Fv, 2*abs(ft_y(Iv))-M) where M=mean(ydat)
Star Strider
Star Strider el 13 de Abr. de 2016
No.
Like this:
M = mean(ydat);
ft_y = fft(ydat-M)/L; % Fourier Transform (Normalised)
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
figure(1)
plot(Fv, 2*abs(ft_y(Iv)))
grid
xlabel('Frequency (Arbitrary Units)')
ylabel('Amplitude (Arbitrary Units)')
davy hanna
davy hanna el 18 de Abr. de 2016
what would the unit of the y-axis be on this graph? x-axis is frequency & Hz
Star Strider
Star Strider el 18 de Abr. de 2016
It would be the same units as ‘ydat’.
davy hanna
davy hanna el 10 de Mayo de 2016
Star Strider
Are they though, the ydat for that example is pulse rates every 5 seconds, during walking. when the fft is plotted, the y-scale is from 0 to a maximum of 5? so am thinking it can't be the ydat of the original form?
Star Strider
Star Strider el 10 de Mayo de 2016
The Fourier transform is what it is, and I stand by my previous statements. It may not be appropriate for your analysis, since your data plotted as a function of time demonstrate a certain periodicity with respect to heart rate, with an increasing heart rate over time. This may be an artefact of your experimental conditions (for example, treadmill velocity, if you are studying heart rate over certain fixed periods of specific treadmill velocities). Since I don’t know what you’re doing, I can’t say with any certainty what analysis techniques are appropriate for your data.
If my ‘treadmill’ guess is correct, perhaps you should be regressing heart rate against treadmill velocity instead of doing a Fourier transform.
I have no idea.

Iniciar sesión para comentar.

david  hanna
david hanna el 14 de Mzo. de 2016

0 votos

Fs = 1000; T = 1/Fs; L = 1000; t = (0:L-1)*T; x = 0:5:120; y = [62,57,56,55,57,56,58,62,62,63,61,61,62,62,62,61,60,60,60,61,65,68,67,66,67]; plot(Fs*t(1:50),y(1:50)) xlabel('time (seconds)')
Index exceeds matrix dimensions.
Getting that index error, maybe i'm not on the right track here for getting the fft even?
davy hanna
davy hanna el 12 de Abr. de 2016

0 votos

xdat = 0:5:120;
ydat = [62,57,56,55,57,56,58,62,62,63,61,61,62,62,62,61,60,60,60,61,65,68,67,66,67];
scatter(xdat,ydat,'filled')
set(gca,'xtick',0:5:120)
grid on
any idea on how to an fft on that plot above?
davy hanna
davy hanna el 13 de Abr. de 2016
Editada: davy hanna el 13 de Abr. de 2016

0 votos

xdat= 0:5:120;
ydat=[62,57,56,55,57,56,58,62,62,63,61,61,62,62,62,61,60,60,60,61,65,68,67,66,67];
plot(xdat,ydat);
nfft=length(ydat);
nfft2=2.^nextpow2(nfft);
ffty=fftshift(fft(ydat,nfft2));
r=abs(ffty);
plot(r);
plot(r); ↑ Error: The input character is not valid in MATLAB statements or expressions.
can anyone tell me how/why im going wrong when trying to plot the FFT of this?

Etiquetas

Preguntada:

el 8 de Mzo. de 2016

Comentada:

el 10 de Mayo de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by