필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How can I calculate an integral in a for-loop?

조회 수: 2 (최근 30일)
Max
Max 2016년 1월 22일
마감: Walter Roberson 2016년 1월 23일
Hello,
I´ve got a few problems with the code below. What I would like to do ,here, is to evaluate the function logL. Therefore, I have to evaluate the functions (I, y and logL) in the for loop, for all of the four data points, tfail.
But it doesn´t work. I can´t find the mistake. Can somebody help me, please?
clear all; close all
tfail = [5571.760,5573.742,5654.457,6079.693]
n = length(tfail)
beta_hat = 4.2915822
B_hat = 1861.6186657
C_hat = 58.9848692
syms t B beta C
y(t) = (exp(-B/((heaviside(t)-heaviside(t-2000))*(330)+(heaviside(t-2000)-heaviside(t-3000))*(350)+...
(heaviside(t-3000)-heaviside(t-14000))*(390))))/C;
logL=0;
for i=1:n
tfail(i)
I = int(y,t,[0,tfail(i)]) % integrate y from t=0 to t=t(i)
y_new(i)=subs(y,t,tfail(i)) % evaluate y(t) at t=t(i)
logL =logL+log((beta*y_new(i).*(I_(i)).^(beta-1)).*exp(-((I_(i)).^beta)));
end
%%figure(1)
logl = subs(logL,{beta,B,C},{beta_hat,B_hat,C_hat}) % plot logL for different beta, B, C ???
ezplot(logL,[0,4000])

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by