How to use least-square fit and gaussian surface for 3D data?

11 views (last 30 days)
I have followed the mentioned research papers to calculate the heat footprint using gaussian curve fit. (Land surface temperature images are used to calculate the urban heat island and its spatial extent which is called heat footprint.) https://doi.org/10.1016/j.rse.2014.05.005, https://doi.org/10.3390/a8020082, https://doi.org/10.1016/j.apgeog.2021.102496
Unfortunately, none of these authors have any MATLAB file uploaded here that can help me. Also I tried to look for least square planar fit to find the offset of gaussian equation, since I am new on MATLAB, it is getting a little hard to understand which one is correct and how to use all those results.
Also I used the curve fitting tool but it does not have an option to use gaussian for 3D data. Can anybody help me regarding gaussian surface fit for 3D data?
Thank you

Answers (1)

Matt J
Matt J on 12 Dec 2023
This FEX file will fit a Gaussian with a constant background in any dimension,
  2 Comments
Deepshikha Deo
Deepshikha Deo on 18 Dec 2023
Thank you for the answer.
As I checked this FEX file, there are two data: xdata and zdata which are necessary. Thus I created a 4834x2 double type with the name 'xdata' and 4834x1 double type with the name 'zdata' in the workspace. As I run the code I get error
gaussfitn
Not enough input arguments.
Error in gaussfitn (line 58)
[M,N]=size(xdata);
How should I deal with it?
I have attached the csv file I used to create the two matrix. In this csv the first two columns are of xy coordinates and the third column has zvalues (temperature data).
Thank you
Matt J
Matt J on 18 Dec 2023
Edited: Matt J on 18 Dec 2023
I can't explain it. It runs fine in the online Matlab engine:
[x,y,z]=readvars("JP_LST.csv");
p=gaussfitn([x,y],z)
Local minimum possible. lsqcurvefit stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
p = 1×4 cell array
{[21.9097]} {[661.5662]} {2×1 double} {2×2 double}

Sign in to comment.

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!