Problem fitting with lsqcurvefit
Afficher commentaires plus anciens
im getting the following error while executing the code "Index exceeds the number of array elements (2)", the goal is to fit a curve to points using a certain Formula:

[name,path]=uigetfile({'*.xlsx'});
filename = [path name];
opts = detectImportOptions(filename);
preview(filename,opts);
newtable = readtable(filename);
x = newtable{:,1};
y = newtable{:,2};
fun = @(w,x) sqrt(w(1)^2+w(2)^2*(x-w(3))^2)
x0 = [1 1];
w = lsqcurvefit(fun,x0,x,y)
Réponse acceptée
Plus de réponses (1)
Your model has 3 unknowns w(1), w(2), and w(3). However, you are only providing initial guesses x0 for 2 of these variables.
Catégories
En savoir plus sur Least Squares dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
