MATLAB: How to fit a curved surface to 3d data points and determine normal at each point on the surface

normal on the surfacesurface fiting

I have a set of points in 3d that I want to fit a surface to
X Y Z
88.34884266 70.92106438 34.88876326
88.48635951 70.96269708 34.8772813
88.52449563 70.97312221 34.8750546
88.55783302 70.98193287 34.87336454
88.77013814 71.03417232 34.86545322
88.83835974 71.05075785 34.86235067
88.91521736 71.07019932 34.85720189
88.98176267 71.08807474 34.85069521
89.1849645 71.14889922 34.81739701
89.18878743 71.15012961 34.81656531
89.29523472 71.18552462 34.79034526
89.38987985 71.21858 34.7623053
89.51581158 71.26427043 34.71866249
89.58510321 71.29006986 34.6917181
89.65542814 71.31664706 34.66231761
89.77484354 71.36240788 34.60799271
89.83131134 71.38413649 34.58068214
89.96085257 71.43357417 34.51520405
89.99956324 71.44813194 34.49506547
90.13865425 71.49919243 34.42134953
90.14557114 71.50167157 34.41764679
90.33031316 71.56588888 34.31744518
90.33977141 71.56908362 34.31223393
90.44533224 71.60418891 34.25373427
90.51517712 71.62684469 34.21532681
90.68251281 71.67958435 34.12770077
90.70271616 71.68596618 34.11764817
90.75639914 71.70318951 34.09150462
90.89246796 71.75002701 34.02886219
91.03062652 71.80598991 33.96863779
91.06922783 71.82389505 33.95196593
91.07953868 71.82889226 33.94750915
91.16963831 71.87738557 33.90845956
88.1453716 70.84427249 34.91168477
91.2557964 71.93460946 33.87083067
91.14272667 72.12711523 33.95139498
91.11447786 72.17499203 33.96959179
91.05811704 72.26995939 34.00400268
91.0298574 72.31727119 34.02042715
90.96906323 72.41847681 34.05424141
90.87793668 72.56909815 34.10208093
90.85324486 72.60974076 34.11462009
90.82070834 72.66317105 34.13088858
90.67002072 72.90821977 34.20245321
90.66270133 72.91999601 34.20576287
90.64366913 72.95054643 34.21428469
90.51564106 73.1528487 34.26797188
90.43946314 73.26982856 34.29623437
90.42604562 73.2900915 34.30084966
90.35483116 73.39563974 34.32323649
90.19870967 73.61306846 34.35799793
90.19121251 73.62294898 34.35912243
90.18311614 73.63355655 34.36027821
89.99563354 73.86060892 34.37017039
89.92703566 73.93541533 34.36648418
89.79146056 74.07218898 34.34977241
89.63260392 74.21806984 34.31838969
89.62374491 74.22586507 34.31637378
89.57459558 74.26859236 34.30480439
89.35109965 74.45487106 34.24675338
89.32238543 74.47821727 34.2389782
89.30396908 74.49315474 34.23398393
89.12515812 74.63698837 34.18521456
89.0076698 74.73064072 34.15289243
88.97979247 74.75279776 34.14515539
88.89848968 74.81730788 34.12220856
88.69322676 74.97974336 34.05933935
88.67287417 74.99586084 34.05252979
88.65640958 75.00891017 34.04692389
88.45165891 75.17288789 33.96813898
88.38710606 75.22607619 33.93867974
88.34383121 75.26267336 33.91714006
88.24389318 75.35182661 33.86009207
86.2297349 74.08929113 35.42796756
86.25527688 74.10248899 35.4049097
86.36508254 74.1629912 35.30908771
86.38590954 74.17483977 35.29161129
86.47298114 74.22537368 35.22027829
86.60971332 74.30743603 35.11230418
86.65196656 74.33337463 35.0796883
86.72045408 74.37592104 35.02740876
86.85613911 74.4617756 34.92555087
86.91972279 74.50264398 34.87853277
86.96891189 74.5345272 34.8424873
87.10327493 74.62335184 34.74586378
87.18820228 74.68128975 34.68645524
87.21790728 74.70180428 34.66590506
87.35065786 74.79387486 34.57459938
87.45731705 74.86646582 34.50114362
87.46757379 74.87330677 34.49404711
87.59943415 74.95969686 34.40095864
87.71654254 75.03540861 34.31295071
87.72572481 75.04132242 34.30576642
87.84201504 75.11574822 34.21079344
87.95709075 75.18683677 34.11210712
87.98494791 75.20342533 34.08799397
88.08037508 75.25875273 34.0049957
88.10152074 75.27076695 33.98652299
86.12256277 74.04465347 35.52202228
88.06397993 70.99354692 35.01256578
88.04693381 71.02320192 35.03100836
88.04251856 71.03081315 35.03566506
87.9764144 71.14193849 35.10037671
87.92765914 71.2213428 35.14332252
87.88935775 71.28272723 35.17497211
87.85324302 71.34008195 35.20351883
87.80605669 71.41458727 35.23940644
87.72223869 71.54685969 35.3008879
87.68258732 71.60987932 35.32964257
87.67667746 71.61930979 35.33392795
87.56064872 71.80686956 35.41856128
87.55611413 71.81430624 35.4219029
87.50296113 71.90210448 35.46115717
87.44103907 72.00575373 35.50651906
87.3939741 72.08540696 35.5401319
87.33277789 72.18968697 35.58105811
87.32234699 72.20749286 35.58754333
87.23112546 72.36278482 35.63558161
87.20116733 72.41337482 35.64766126
87.1582768 72.48521127 35.66185336
87.07482444 72.62245839 35.67968558
87.0598892 72.64670921 35.68174441
86.97365856 72.7858986 35.6895499
86.9444749 72.83295067 35.69126736
86.88242517 72.9332052 35.69413937
86.81392313 73.04425595 35.69624174
86.78670637 73.0884921 35.69680643
86.70532782 73.22052995 35.69682154
86.68364461 73.25545558 35.69614652
86.59910718 73.38950222 35.68942722
86.55111133 73.46354138 35.68219827
86.52496651 73.5030869 35.67711655
86.41345125 73.66454606 35.64599988
86.40308414 73.67896942 35.64240295
86.33470693 73.77192092 35.61645838
86.26972058 73.85715198 35.58910334
86.2056841 73.93912141 35.56049859
86.19536303 73.95223376 35.55578151
I want to fit a smooth surface using these 3d points and also want to determine the normal at each point on the surafce

Best Answer

Um, lets be serious. You don't have a curved surface. Nor do you have sufficient information to define any surface with any degree of comfort. You have the boundaries, in the form of simple (nonlinear) curves.
There is no surface that can be rationally fit. Worse, your surface is not even aligned with the axes, nor are the edges straight lines in the (x,y) plane.
And, not only do you want to compute a surface, you want to compute surface normals too? I assume you know what ROFLMAO suggests? Sorry but you can want to do whatever you want. But to achieve the impossible, I can only wish you luck.
Yes, I know that someone will suggest the use of a 2-dimensional polynomial model. Don't believe them in the slightest. This data is absolutely, patently, worthless to determine the many necessary coefficients of a polynomial model with two independent variables.
Some people might even suggest my own gridfit tool. Actually, it did not do as bad here as I might have expected. But gridfit also will extrapolate to the boundaries of the smallest rectangle that is aligned with the x and y axes. So quite a ways out.
You could, in theory, compute the normal to every facet in that surface. Remember that most of those facets actually are outside the support of your data. And the rest of them lie inside, where gridfit was forced to do heavy intrapolation. (Extrapolation across a large internal hole.)
Sorry, but I have little confidence in the surface shown above, and my own code produced it.