How to find parameters that minimize a difference

4 views (last 30 days)
vinxp on 8 Nov 2021
Edited: Alan Stevens on 10 Nov 2021
Hi everyone, I have to solve an equation numerically. I thought to split it into two parts and to calculate the difference between them setting a first try column vector and 4 first try parameters. How can I get the 4 parameters that minimize the obtained column of differences? Thank you.
Here is the code for the first part:
k=1.53E4;
kp=5.8E4;
c=1.11E6;
g=1; %first try parameters
t=[2:2:480]';
x=Strain; %Strain is a column vector 240x1
y=[zeros(1,length(x))]';
y1=((c./t).*x.*(exp(-k.*t/c)).*(-1+exp(k.*t./c))+x.*kp);
y2=(54000-x.*g.*(1-exp(x)).^2);
for i=1:(length(x))
y(i)=y1(i)-y2(i);
end

Alan Stevens on 8 Nov 2021
Use fminsearch and use the norm of the differences.
help fminsearch
Alan Stevens on 10 Nov 2021
deleted

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by