17 views (last 30 days)

I have a set of data made up of values between 0 and 1:

biglambda = [ 0.0455 0.0476 0.0500 0.0526 0.0556 0.0588 0.0625 0.0667 0.0714 0.0769 0.0833 0.0909 0.1000

0.1111 0.1250 0.1429 0.1667 0.2000 0.2500 0.3333 0.5000 1.0000]

I want to fit this to a functional form, given by

where a and b are free parameters, t is a time parameter:

t = 1*10^3*[0.5156 0.5693 0.6444 0.6698 0.6730 0.6850 0.8073 0.8615 0.9927 1.0587 1.0791 1.1747 1.1827 1.2286

1.2917 1.2967 1.3735 1.3735 1.3735 1.3924 1.7004 1.9965]

such that each value of biglambda will have its own value of t (in the order shown). T is the time bin, i.e. the time between different values of t. I want to use these parameter sets to find the correct values for a and b that give a suitable fit to the data. My first thought for how to solve this would be to do something of the form

where i is the ith value of biglambda or t, and then minimise this for a and b. However, I'm not sure which is the best approach to take in Matlab for calculating this, as I would normally write a function for , but as I have a set of values I need to take the sum of this seems to be more complicated. I have started with

for j = 1:length(t)

BigLambdaFunction = @(x)biglambda(j)-(1-x(1)*(x(2)-(t(j)+(t(j+1)-t(j))))/(x(2)-t(j))*exp(x(1)*(t(j+1)-t(j))/x(2)));

end

for each j, but I'm not sure how I can convert this to calculate the whole sum and minimise for x(1) and x(2). What would be a good place to start?

Star Strider
on 11 Dec 2019

Try this:

BigLambdaFunction = @(p,t,T) 1 - p(1).*((p(2)-(t-T))./(p(2)-t)).*exp((p(1).*T)./p(2))

biglambda = [ 0.0455 0.0476 0.0500 0.0526 0.0556 0.0588 0.0625 0.0667 0.0714 0.0769 0.0833 0.0909 0.1000 0.1111 0.1250 0.1429 0.1667 0.2000 0.2500 0.3333 0.5000 1.0000];

t = 1;

T = 42;

p0 = rand(2,1);

Parms = fminsearch(@(p) norm(biglambda - BigLambdaFunction(p,t,T)), p0)

I have no idea what ‘t’ and ‘T’ are supposed to be, so if they are vectors, it will be necessary to loop through the individual values and estimate ‘Parms’ at each of them. In this code, ‘Parms’ is a (2x1) vector, with ‘a=p(1)’ and ‘b=p(2)’.

Star Strider
on 11 Dec 2019

The ‘Parms’ vector at each value of ‘t’ and ‘T’ are the parameters:

a = Parms(1)

b = Parms(2)

Opportunities for recent engineering grads.

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

Start Hunting!
## 0 Comments

Sign in to comment.