How to get a period of cosinus function ?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ilan Moshe
el 25 de Mayo de 2020
Comentada: Ilan Moshe
el 27 de Mayo de 2020
Hi,
I have to find the period of the cosinus function using only the vector time and the vector data of the function.
![Cosinus function](https://www.mathworks.com/matlabcentral/answers/uploaded_files/300118/Cosinus%20function%20.png)
![Vector data](https://www.mathworks.com/matlabcentral/answers/uploaded_files/300123/Vector%20data.png)
![time data](https://www.mathworks.com/matlabcentral/answers/uploaded_files/300128/time%20data.png)
2 comentarios
Rik
el 25 de Mayo de 2020
This looks like the sum of two cosines, not just one. Do you want the cosine with the largest magnitude? Are you allowed to use a Fourrier transform?
Respuesta aceptada
Rik
el 25 de Mayo de 2020
Editada: Rik
el 25 de Mayo de 2020
Because this is homework, I won't provide a copy-paste ready solution.
If you follow the example from the documentation for fft, you get the code below.
%recreate data
delta_t=0.1;Tlim=5;f=[1;2];
t=0:delta_t:Tlim;
x=sum(cos(2*pi*t.*f));
%figure(1),clf(1)
%plot(t,x)
Fs=1/mean(diff(t));%sampling frequency
L=numel(x);
Y = fft(x);
P2 = abs(Y/L);
P1 = P2(1:floor(L/2)+1);
f = Fs*(0:(L/2))/L;
figure(1),clf(1)
plot(f,P1,'-*')
title('Fourrier transform'),xlabel('frequency'),ylabel('magnitude')
Now you can clearly see there are two frequencies that have a high magnitude.
3 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Discrete Fourier and Cosine Transforms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!