How to plot a Damped and driven oscillation

I try to compute a simple damped and driven oscillation but it just won't work out. Is there anybody who can help me? This is my code:
q = [0:10];
q = q(:);
for(x=1:10)
q(x);
for(t=0:0.1:1)
q(x)= exp(-t)*(exp(2*t)-exp(-2*t));
end
end
plot(q)

1 件のコメント

suman shah
suman shah 2021 年 12 月 28 日
for dot product use .* together

サインインしてコメントする。

回答 (1 件)

Chad Greene
Chad Greene 2017 年 7 月 19 日

0 投票

Hi Lukas,
For starters, it looks like you're doing a lot of unnecessary steps. I think the code above can be rewritten simply as
t = 0:0.1:1;
q = exp(-t).*(exp(2*t)-exp(-2*t));
plot(t,q)
However, that's not going to give you a damped oscillation. Maybe you want something more like this?
t = 0:0.1:100;
q = exp(-t/10).*sin(2*t);
plot(t,q)

4 件のコメント

Lukas Goldschmied
Lukas Goldschmied 2017 年 7 月 19 日
Thanks for your help. This is not exactly what i was looking for. It should look like this in the end: https://lp.uni-goettingen.de/get/image/2285
Chad Greene
Chad Greene 2017 年 7 月 20 日
What's the mathematical expression for the signal you're trying to plot?
Lukas Goldschmied
Lukas Goldschmied 2017 年 7 月 20 日
a*exp(-gt)*sinh(a*t) with and g are const.
Chad Greene
Chad Greene 2017 年 7 月 20 日
This should do the trick:
a = 5;
g = 7;
t = 0:0.01:1;
q = a*exp(-g*t).*sinh(a*t);
plot(t,q)

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

質問済み:

2017 年 7 月 19 日

コメント済み:

2021 年 12 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by