How to create a sine wave over given no of samples

7 vues (au cours des 30 derniers jours)
Leif Bohné
Leif Bohné le 10 Mar 2018
Commenté : Leif Bohné le 10 Mar 2018
Hi.
I am trying to create a sine wave with an arbitrary frequency over 2048 samples for an audio sample, but since I'm new to Matlab and my math is a little bit rusty I simply can't get it to work. I'm sure there's some simple way to generate this buy I've been trying to search the net but don't really know how to formulate my searches so that I find an answer for my specific case. I would be really thankful if you guys could help out.
So my question is how to create an array of 2048 elements that represent a sine wave where the frequency is a natural number. Could be 1 cycle or any other.
Thanks.
/Leif.

Réponse acceptée

Stephen23
Stephen23 le 10 Mar 2018
Modifié(e) : Stephen23 le 10 Mar 2018
smp = 2048;
cyc = 2.5;
X = linspace(0,cyc*2*pi,smp);
Y = sin(X);
plot(X,Y)
  1 commentaire
Leif Bohné
Leif Bohné le 10 Mar 2018
Hi! Thanks, it seems to be what I'm looking for.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by