How to do a damped sine wave

54 views (last 30 days)
Big AL
Big AL on 16 Feb 2016
Commented: jay shah on 8 Aug 2017
Hi I am trying to do a damped sine wave, but my program is not working. Can someone please tell me what I am doing wrong? Here is my code.
A=10;f=1000;n=5;T=1/f;t=[0:T/100:n*T];s=A*exp(-t).*sin(2*pi*f*t);
plot(t,s)
  3 Comments
Star Strider
Star Strider on 17 Feb 2016
Hi Walter!
I laughed out loud when I read your comment!
jay shah
jay shah on 8 Aug 2017
Hi. Include some constant in "exp(-t)" part of your function. Make it like exp(-B.*t) and choose B = 1000 or any other value depending on how much damping you want.

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 16 Feb 2016
Please describe ‘not working’.
It runs without error for me, and plots the appropriate sine curve. If it’s not damping quickly enough for you, multiply the ‘-t’ in the exponential by some constant (here 1000). Change the constant to produce the result you want.
For example:
A=10;f=1000;n=5;T=1/f;t=[0:T/100:n*T];s=A*exp(-t*1000).*sin(2*pi*f*t);

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!