Optimization Curve Fitting: Curves are not converging

4 views (last 30 days)
I'm trying to fit some experimental data with a mathemtical model. I'm trying to using Optimization techiques to do the fitting, namely "fminsearch, and fmincon". However, and as you can see in the attcahed plot image, the cuvres do not match. They do some how have simlar shaeps, and tried to follow MATLAB's guide on the topic as well.
My fitting parametres are:
  • Q. (Highest Priority)
  • Total (2nd Highest)
  • S1 and 2.
  • Tep.
I have attached my sample data along with my code. It takes a little while to run but it works. Looking forward for your help, and thank you in advance.
  6 Comments
Matt J
Matt J on 8 Feb 2023
Edited: Matt J on 8 Feb 2023
Thanks you for that part, but the calculation of Pre is still quite slow and it is unnecessary for your question to have us repeat it. If you have already done the part below, then just attach all these pre-calculated variables in a .mat fil (one file, not several).
Experiment = importdata('Data.txt');
Real_Time = Experiment(:,1);
Real_Pre = Experiment(:,2);
%If it is taking so long, this will make it faster
% Real_Time = downsample(Experiment(:,1),20); %s
% Real_Pre = downsample(Experiment(:,2),20); %Torr
Qp = 10;
Total=8e16;
Tim= Real_Time;
S1= 15;
S2=50;
Tep= 293;
Pre=Fitt_Test(Qp,Total,Tim,S1,S2,Tep);
Trung
Trung on 8 Feb 2023
Again. I really apoligize for the trouble. I have attached the run resutls as a Mat file.

Sign in to comment.

Answers (1)

Matt J
Matt J on 8 Feb 2023
Edited: Matt J on 8 Feb 2023
One immediate problem that I see is that in sseval, the optimization variables x(i) aren't used at all in the calculation of sse. That's what the squiggly red underlines are trying to warn you of:
  16 Comments
Matt J
Matt J on 9 Feb 2023
Edited: Matt J on 9 Feb 2023
Maybe you didn't understand what I meant by "do an exhaustive search". Since you now have only 2 unknown variables, you can use surf() to plot sseval as a 2D surface and see where its minimum lies. If desired, you could then run fmincon with the initial guess x0 chosen to lie where the minimum appears to be on the surf plot.
Trung
Trung on 9 Feb 2023
I will try that. Thank you very much for your kind help.

Sign in to comment.

Categories

Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!