フィルターのクリア

How to multiply function handles?

32 ビュー (過去 30 日間)
Max
Max 2016 年 1 月 22 日
コメント済み: James Morrison 2023 年 2 月 6 日
Hello,
I would like to calculate and to plot the following equation:
f(t,x) = (beta_hat*s(t,x)*[I(t,x)]^(beta_hat-1))*exp(-[I(t,x)]^beta_hat)
where:
s(t,x): step-function(330 for x=[0;2000])
(350 for x=[2000;3000])
(390 for x=[3000;4000])
I(t,x): Integral(exp(-B_hat/x(u))/C_hat)) from x=0 to t
beta_hat, C_hat and B_hat are known parameters
My MATLAB-script looks like that:
beta_hat = 4.2915822
B_hat = 1861.6186657
C_hat = 58.9848692
%%Step-function x(t)
syms t
y(t) = (exp(-B_hat/((heaviside(t)-heaviside(t-2000))*(330)+(heaviside(t-2000)-heaviside(t-3000))*(350)+...
(heaviside(t-3000)-heaviside(t-4000))*(390))))/C_hat;
fnum=matlabFunction(y);
Inum=@(x)integral(fnum,0,x);
f = @(x)(beta_hat*fnum(x).*Inum(x).^(beta_hat-1)).*exp(-(Inum(x).^beta_hat))
ezplot(f,[0,14000])
But if I plot my function f the figure isn´t right. There should be a smooth curve, similar to the bell-shaped curve.
Does anybody recognize my fault?

採用された回答

Walter Roberson
Walter Roberson 2016 年 1 月 22 日
What value are you assuming that heaviside(0) has?
As you are working with the Symbolic toolbox anyhow, have you considered doing a symbolic integration with int() instead of changing to a numeric function and using integral() ?
  3 件のコメント
Max
Max 2016 年 1 月 22 日
Hi Walter,
thank you for your answer. I found found the mistake. It wasn´t a problem in MATLAB, but in a mathematical equation.
Walter Roberson
Walter Roberson 2016 年 1 月 22 日
heaviside(x) is defined to be 0 for x < 0,, and is defined to be 1 for x > 0. You cannot have heaviside(t=4000) be 390 .
The value of heaviside(x) for x = 0 is not precisely defined. In some systems, heaviside(0) is undefined. In some systems, heaviside(0) is 1/2 . In some systems, heaviside(0) is 0. In some systems, heaviside(0) is 1.
As of R2015a, you can use the new sympref() to control the value that is used for heaviside(0)
Remember, no matter what value you use, heaviside is discontinuous, so you should avoid using numeric integration with it, unless you split your integral up into disjoint ranges at each boundary, integrate each separately, and total the results.

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

その他の回答 (1 件)

Tiago Araujo
Tiago Araujo 2021 年 6 月 24 日
I need to do a integral with a function by combining two functions, something like this:
syms q r
x(q,r) = q + 2*r;
y(q,r) = q*9 + r;
G = @(q,r) x+y
integral2(G,1,2,1,2)
It is only a example, my real problem is much more complex. How can i do that?
  5 件のコメント
Tiago Araujo
Tiago Araujo 2021 年 6 月 24 日
You're great! Thanks, matlabFunction solved my problem! I didnt know this function.
James Morrison
James Morrison 2023 年 2 月 6 日
Thank you @Steven Lord! worked perfectly :)

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

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by