How can I fit a function that takes a range of x as input instead of just one value?
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a set of measured data and a function that can be used to simulate that data (found online on a publication). The problem is that the function takes a range of x such as 40:0.01:50 as input, as well as some other parameters. I tried to use the fit function, but since it evaluates the function at each x, it doesn't work since I get the error of "Not enough input arguments". I wanted to use the fit function as it is simple to introduce ranges for the fitting parameters that I want to use with lower and upper. Is there any other way to do this or a solution?
4 Commenti
Torsten
il 6 Lug 2022
We cannot give advice with the information given.
The usual fit functions use one input for x and parameters to produce one output y. That's what all optimization routines of MATLAB are based on.
Why does the function need a range of x-values as input to produce one (?) output y ?
Risposte (1)
Image Analyst
il 6 Lug 2022
Modificato: Image Analyst
il 6 Lug 2022
Just make your code prepared to handle vectors, like
x = 40:0.01:50;
y = MyFun(x)
function y = MyFun(x)
y = x .^ 2;
end
Vedere anche
Categorie
Scopri di più su Get Started with Curve Fitting Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!