Help: Difficult in optimising these ODE 45 equations
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
First file
function chisquare = myObjective(P)
a = P(1);
b = P(2);
c = P(3);
d = P(4);
sigma = 180;
hstress = 3463.46;
Hstar = 0.7846;
Kc = 0.1137;
tspan = 0.3722:1:10;
initial_conditions = [0;0;0;0];
[t,y] = ode45(@(t,y)pair1(t,y,a,b,d,hstress,sigma,Hstar,Kc,c),tspan,initial_conditions) %function call
pred=y(:,1);
for i=1:length(t)
expn(i) = exp(i+1)
end
plot(t,expn)
hold on
plot(t,pred)
hold off
chisquare =0;
for i=1:length(pred)
chisquare = chisquare+(pred(i)-expn(i)).^2;
end
end
Second script File
function dy=pair1(t,y,a,b,d,hstress,sigma,Hstar,kc,c)
dy=zeros(4,1);
dy(1) = a*sinh((b*(sigma^d)*(1-y(2)))/((1-y(3))*(1-y(4)))) ;
dy(2) = ((hstress*(a*sinh(b*(sigma^d)*(1-y(2)))/(1-y(3))*(1-y(4))))/(sigma^d))*(1-y(2)/Hstar);
dy(3) = (kc/3)*power((1-y(3)),4);
dy(4) = c*y(1);
end
Third script file
X=csvread('0.18_250MPa.csv');
exp=X(:,2);
P = [0.001 0.1 0.1 0.001];
op = optimiza(P)
Text file is attached below.. Please find the attachment
Ending with the error
Error using myObjective (line 2)
Not enough input arguments.
I suspect I know a bit of what's going wrong.. yet I'm at a loss for how to fix it.. Any help is much appreciated
1 Kommentar
Star Strider
am 24 Jul. 2019
If you are intending to fit your differential equations to data see:
There are some others as well, however these are the most illustrative.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!