Can anyone help to write a code for plotting the following equation with time please?

x = exp( (-B/omega) * cos(omega * t) ) ...
./ ( (B/A)*(integral(exp( (-B/omega)* cos(omega * t) ))))
Where
A= 1;
B= 10;
omega= 1;
x0 =0.1;
t = 0 :0.0001:1000;

3 件のコメント

Avan Al-Saffar
Avan Al-Saffar 2015 年 2 月 9 日
The above result is for solving the following system analytically:
dx/dt = (B*sin*(omega*t) * x) - (x^2 * B / A)
Roger Stafford
Roger Stafford 2015 年 2 月 9 日
As it stands, the integral in your expression is an indefinite integral and therefore has an arbitrary constant of integration. You need to specify what that constant is in order to successfully plot x as a function of t.
Avan Al-Saffar
Avan Al-Saffar 2015 年 2 月 9 日
We can find the constant at x(t=0).

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

 採用された回答

per isakson
per isakson 2015 年 2 月 9 日
編集済み: per isakson 2015 年 2 月 9 日
With a little bit of guessing
A= 1;
B= 10;
omega= 1;
x0 =0.1;
t = 0 :0.0001:1000;
fi = @(ti) exp( (-B/omega).*cos(omega*ti) );
fx = @(tj) exp( (-B/omega) .* cos(omega*tj) ) ...
./ ( (B/A).*(integral( fi, 0, tj )));
ezplot( fx, 0:1e-3:12*pi )
produces this
&nbsp
I don't use x0 =0.1; and I get a warning
Warning: Function failed to evaluate on array inputs; [...]

4 件のコメント

Avan Al-Saffar
Avan Al-Saffar 2015 年 2 月 10 日
編集済み: Avan Al-Saffar 2015 年 2 月 10 日
Many thanks, this is really useful. If I want to find Max(x) and Mean(x), can you help me to find those as well please?
Torsten
Torsten 2015 年 2 月 10 日
Note that x(0)=Infinity since you get a division by zero there for your quotient.
Best wishes
Torsten.
Avan Al-Saffar
Avan Al-Saffar 2015 年 2 月 10 日
But I have cos(omega*t) in the denominator so if t =0, I will get 1 .
Torsten
Torsten 2015 年 2 月 10 日
If lower limit and upper limit of an integral are identical (t=0 in this case), its value is zero - independent of the function to be integrated.
Best wishes
Torsten.

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

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by