I am trying to do regression non-linear on a data of force-displacement. I would like to ask how to know the equation in advance (as you mostly do know at the start of your videos related to regression) without doing the fit first? I have a data with strain-hardening behavior
Coming up with the correct form of the equation is typically based on physics-based principles. Another approach is to use machine learning where the equations are determined by the algorithm: apmonitor.com/pds/ (see Regression section).
Good video, would it be possible to run a Simulink model within a loop, saving outputs to use as the data each time and change workspace variables to optimise how the model runs?
Great video I tried to use this code with a p(1) + p(2).*x+p(3).*(x).^2 and this error pops up Unrecognized function or variable 'getIpOptions'. Error in fmincon (line 822) options = getIpOptions(options,sizes.nVar,mEq,flags.constr,defaultopt,10,0.01); Error in Program1 (line 323) popt = fmincon(obj,p0); The code is the same as yours and i don't know what to do
It sounds like it could be a problem with your MATLAB installation or compatibility of a toolbox. APMonitor MATLAB toolbox is another option if that doesn't work for you: apmonitor.com/che263/index.php/Main/MatlabDataRegression or you could try Python: apmonitor.com/che263/index.php/Main/PythonDataRegression
Thank you John, this is an excellent video! Thank you for the tutorial! My problem is that I wrote the same command with you . But the results I got are dependent on the random number I gave to P0 at the beginning, which means that if I input p0=[1,2] and p0=[2,3], I will get a totally different Popt. I don't know even how to describe this problem in Google >
Initial guesses are important, especially with less powerful solvers. See the Gekko solution to the same problem here: apmonitor.com/che263/index.php/Main/PythonDataRegression
excuse me. thanks for the great tutorial. but, I want to ask something. in initial, there is the function y = p1 + (p2/x) + ln(x)*p3. is that equation an objective function for optimization? if it is so, what is the constraint? and, I think xm and ym can be plotted in excel file, so we shouldn't put xm and ym in MATLAB script. i.e. we import it from excel to MATLAB as an alternative. could it be? thank u so much.
No, the equation is the constraint. The objective function is a measure of how well the data fits the predicted output (y) based on the input xm such as (y-ym).^2 Here is information on importing data files into Matlab: apmonitor.com/che263/index.php/Main/MatlabDataAnalysis It is easier if you save the file as a CSV type first.
Another great video! I commented extensively on one of your other videos. I have further narrowed it down to the following: I keep getting this error: "Error using fmincon (line 619) Supplied objective function must return a scalar value." I think its due to the fact that I have more than one set of xm and ym's, i.e. [xm, ym; xm, ym; ....;......]. Any comments?
Sir thnx for ur tutorial! but I have a problem, Where I want to solve an error regression with an objective function contains a parameter contains three values at the same time, one always remains fixed and for the other two takes a value it depends on tells conditions how I can do that please !
fmincon is a general purpose solver while polyval is just for fitting polynomials to data. See apmonitor.com/che263/index.php/Main/MatlabOptimization and apmonitor.com/che263/index.php/Main/MatlabDataRegression
You may need to wait for the video to buffer for 1080p video resolution. Higher quality video is available but may be limited by your bandwidth. This method should also work with noisy data. See apmonitor.com/che263/index.php/Main/PythonRegressionStatistics for another example with a user-defined function.
Hello sir,it is really very usefull lesson. I am facing trouble and I hope to help me in coding. I want to separate the coeffisions to solve advace problems like below p1=4 p2=.54 p3=-0.1 yp =@(p1,p2,p3) p1+p2./xm +log (xm).*p3 obj=@(p1,p2,p3) sum ((yp (p1,p2,p3)-ym)./ym).^2) p_ottimal =fmincon (pbjective,(p1,p2,p3)) i found error in fmincon can you help me
If it's an error that it didn't converge then you may need to give better guess values for the optimizer. If it still isn't solving then a better optimizer such as APM Matlab may be better.