Help: Difficult in optimising these ODE 45 equations
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Star Strider
le 24 Juil 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.
Réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!