Problem fitting with lsqcurvefit
显示 更早的评论
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)
采纳的回答
更多回答(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.
类别
在 帮助中心 和 File Exchange 中查找有关 Least Squares 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
