MATLAB
How to optimize the Parameters in my code
Posts  1 - 1  of  1
mathematics15
Dear All,

I have a problem regarding the optimization of parameters such that the error should be minimized. As given in the code below, I want to find the best values of parameters (UP1 and UP2) in the given range such that my error minimizes. Can anybody help me in this regard. If there is any example similar to my problem, please let me know. I will be very thankful to you.

Best Regards

------------------------------

clear,clc
global XX
tend = 40;
tspan=1:1:40;

cp1 = 5; cp2 = 3; A1 = 2; rst = 2;

UP1=.2; %%% parameter to be optimized range = [.01 1] %%%
UP2=.7; %%% parameter to be optimized range = [0.5 3] %%%

M =[cp1 0 0 0; 0 cp1 0 0; 0 0 cp2 0; 0 0 0 cp2];

XX=[-rst-cp1*UP1 0 rst 0;
UP1*cp1 0 0 0;
rst 0 -rst-UP2*cp2 0;
0 0 UP2*cp2 0];

options = odeset('AbsTol',1e-10,'RelTol',1e-10,'InitialStep',1e-2, ...
'Mass',M,'Jacobian',XX);

u0 = zeros(4,1);
u0(1) = 1;
[t,u] = ode15s(@call, tspan, u0,options);

n1=[u(3,2) u(7,2) u(end,2)];
n2=[u(3,4) u(7,4) u(end,4)];

e1=[0.3 0.8 1];
e2=[0.5 2 5];

%%%% Objective is to minimize the following error %%%%


error = abs((n1(1)-e1(1))^2+(n1(3)-e1(2))^2+(n1(3)-e1(3))^2+...
(n2(1)-e2(1))^2+(n2(2)-e2(2))^2+(n2(3)-e2(3))^2)


------------------------------

function du = call( t,u )
global XX
du=XX*u;
end

------------------------------
Save
Cancel
Reply
 
x
OK