This question is closed. Reopen it to edit or answer.

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

1 view (last 30 days)
Max on 22 Jan 2016
Closed: Walter Roberson on 23 Jan 2016
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)+...
for i=1:n
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)));
logl = subs(logL,{beta,B,C},{beta_hat,B_hat,C_hat}) % plot logL for different beta, B, C ???

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by