Solving system of ODEs and then get the optimum value for certain parameters.
Show older comments
I want to optimize fro R1 and R2 with the objective function (t_f-1.2e-6).^2+(t_t-50e-6).^2 == 0. Hereis my code that takes R1 and R2 to solve two differential eqns and give me t_f and t_t.
function [t_f,t_t] = fun1(R1,R2)
C1 = 25e-9;
C2 = 1200e-12;
V0 = 10e3;
F = @(t,V) [((1/(R1*C1))*(V(2) - V(1)));((V(1)/(R1*C2))-(V(2)/(R1*C2))-(V(2)/(R2*C2)))];
[t1, V1]=ode45(F,[0 300e-6], [V0 0]);
Vp = max(V1(:,2));
for n=1:size((V1(:,2)),1)
if V1(n,2) == Vp
t_f = t1(n);
elseif ((V1(n,2)-(Vp/2))*1e-3)^2 < 1e-5
t_t =t1(n);
end
end
end
Someone please help me in using optimization tools of matlab like fminsearch or ga to get the optimal values of R1 and R2.
Accepted Answer
More Answers (0)
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!