Whitespaceisfree.Pleasehavepityonthepeoplewhohavetoreadyourcode.
How to do a damped sine wave
54 views (last 30 days)
Show older comments
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
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.
Answers (1)
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);
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!