I have a task in school in which i need to calculate coefficient of this model.
f = Tp + exp(V*z/(2*D))* k * z./(2*(pi*t.^3*D).^0.5) .* exp(-z^2./(4*D*t) - V^2/(4*D)*t)
t is 4:4:420 and T is
[0.0222 0.0167 0.0211 0.0167 0.0200 0.0200 0.0211 0.0222 0.0222 0.0222 0.0228 0.0233 0.0244 0.0278 0.0300 0.0322 0.0333 0.0333 0.0339 0.0350 0.0361 0.0378 0.0389 0.0389 0.0400 0.0417 0.0433 0.0444 0.0444 0.0444
0.0456 0.0456 0.0456 0.0489 0.0511 0.0539 0.0556 0.0567 0.0667 0.0678 0.0756 0.0800 0.0889 0.0900 0.1000 0.1022 0.1089 0.1111 0.1167 0.1211 0.1222 0.1233 0.1244 0.1267 0.1256 0.1233 0.1233 0.1222 0.1222 0.1211 0.1189 0.1122 0.1100 0.1067 0.1033 0.1011 0.1000 0.0978 0.0911 0.0889 0.0878 0.0833 0.0789 0.0778 0.0767 0.0711 0.0678 0.0667 0.0656 0.0656 0.0644 0.0622 0.0589 0.0578 0.0578 0.0567 0.0561 0.0556 0.0556 0.0556 0.0556 0.0556 0.0544 0.0544 0.0544 0.0544 0.0544 0.0544 0.0544 0.0522 0.0522 0.0511 0.0500 0.0500 0.0489]
my goal is to adjust this model to data by minimanization of rms function rmse(T,f) Function is working but it gives wrong values.
My function look like this
clc
clear all
%% data
load OBIEKT.DAT;
t = OBIEKT(:,1)';
T = OBIEKT(:,2)';
%% function
fun = @(x)modelrms(x,t,T);
%% minimalization
x0 = [0 0 0 0 0 ];
[x,fval] = fminsearch(fun,x0);
%% test
k = x(1);
V = x(2);
z = x(3);
D = x(4);
Tp = x(5);
test =Tp + exp(V*z/(2*D))* k * z./(2*(pi*t.^3*D).^0.5) .* exp(-z^2./(4*D*t) - V^2/(4*D)*t);
plot(t,T,'r-',t,test,'b-')
rmse(T,test)
%% minimalization function
function model = modelrms(x,t,T)
k = x(1);
V = x(2);
z = x(3);
D = x(4);
Tp = x(5);
model = rmse(T,(Tp+ exp(V*z/(2*D))* k * z./(2*(pi*t.^3*D).^0.5) .* exp(-z^2./(4*D*t) - V^2/(4*D)*t)));
end
I find out when i calculate coefficients k V z D without Tp in model equation i find values which are better. Than i set this new values as my initial values and add Tp = 0.031 at the start of the model equation
model = rmse(T,(0.031+ exp(V*z/(2*D))* k * z./(2*(pi*t.^3*D).^0.5) .* exp(-z^2./(4*D*t) - V^2/(4*D)*t)));
At this point program compute the best values of coefficient. How can i fix it so the program give me them with Tp at start