# How do i get the sound of a cosine signal

19 views (last 30 days)

Show older comments

Deniz Bozdogan
on 12 Jun 2021

Edited: Scott MacKenzie
on 12 Jun 2021

I am trying to get the sound of a signal with different phases where its frequency is a frequency of a musical note. f=493.88. My code is below.

t=[0:0.2:20];

xc1=cos(2*pi*493.88*t);

xc12=cos(2*pi*493.88*t+pi/4);

xc13=cos(2*pi*493.88*t+pi/2);

xc14=cos(2*pi*493.88*t+pi);

soundsc(xc1, 1000)

When i try to run the sound i just get a tapping sound for 1 milisecond and then it stops. How do get the sound of the signal? Thank you in advance.

##### 0 Comments

### Accepted Answer

Scott MacKenzie
on 12 Jun 2021

You've only got 100 sample points and the sampling rate is too low. Try this...

t=[0:0.2:2000];

xc1=cos(2*pi*493.88*t);

soundsc(xc1, 8000)

##### 4 Comments

Scott MacKenzie
on 12 Jun 2021

Edited: Scott MacKenzie
on 12 Jun 2021

### More Answers (1)

Image Analyst
on 12 Jun 2021

Scott is right on.

For what it's worth, I'm attaching my demo for making a warbling, decaying chirp sound:

##### 0 Comments

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!