How to perform 3D fitting using "nlinfit"
Ältere Kommentare anzeigen
I want to fit a cross-sectional image of a laser beam with a Gaussian function. And I'm thinking of using "nlinfit" to output the parameter covariance matrix. The image size is 1024 x 1344 pixels. The following process was performed, but fitting was not possible.
process
I=double(cdata) % cdata is an array of image intensity distributions(1024×1344)
[h,w]=size(I);[X,Y]=meshgrid(1:w,1:h)
X=X(:);Y=Y(:);Z=I (:)
modelfun=@(b,X,Y)(b(1)+b(2)*exp((-1/2*(1-b(3)^2))*(((X-b(4))/b(5)).^2+((Y-b(6))/b(7)).^2-2*b(3)*(X-b(4)).*(Y-b(6))/(b(5)*b(7)))))
beta0=[15;150;0;600;90;570;85]
[beta,R,J,CovB,MSE,ErrorModelInfo] = nlinfit([X,Y],Z,modelfun,beta0)
When I performed the above process, I got an error if the number of arguments was incorrect.
Can you tell me the right way?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Interpolation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!