How to integrate a symbolic function?

4 ビュー (過去 30 日間)
Max
Max 2016 年 1 月 22 日
コメント済み: Max 2016 年 1 月 23 日
Hello,
I´m trying to integrate a symolic expression. Therefore I use the MATLAB command "int". But the problem is that it seems like Matlab doesn´t calculate that integral. If I try to convert the result into a numeric number: double(result) then I will get an error.
Could somebody help me, please?
This is my code:
tfail = [5571.760,5573.742,5654.457]
n = length(tfail)
beta_hat = 4.2915822
B_hat = 1861.6186657
C_hat = 58.9848692
syms t B beta C
y(t) = (exp(-B_hat/((heaviside(t)-heaviside(t-2000))*(330)+(heaviside(t-2000)-heaviside(t-3000))*(350)+...
(heaviside(t-3000)-heaviside(t-14000))*(390))))/C_hat;
logL=0;
for i=1:n
tfail(i)
I(i) = int(y(t),t,0,tfail(i))
y_new(i)=subs(y,t,tfail(i))
logL =logL+log((beta*y_new(i)*(I(i))^(beta-1))*exp(-((I(i))^beta)))
end
PS: for i=1, I should get for the integral I(t=5571.76)=0.57185

採用された回答

Walter Roberson
Walter Roberson 2016 年 1 月 23 日
You have subs(y,t,tfail(i)) when y is a function. You invoke functions on values, not subs() the values.
y_new(i) = y(tfail(i))
  2 件のコメント
Max
Max 2016 年 1 月 23 日
Thank you, Walter. That´s it.
Max
Max 2016 年 1 月 23 日
In the case above, y_new(i) yields values because B_hats etc. are known. But in general, it should be a function.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by