Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.7K Views
|
6 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Construct a surface using NonlinearModelFit?

Posted 6 years ago

Hello everyone.

I have a matrix 40000*3. The first column are X positions, the second, Y positions and the third, values of f(x, y). I have used NonlinearModelFit to find a polynomial which fits said data (called F). The problem is that I need a huge number of terms. I have been asked to plot this new surface using Matlab.

I would like to know if it is possible to evaluate the polynomial F at the points defined by the pairs X and Y positions obtaining as a result a vector of size 40000*1 which later on I can export to Matlab, where I can use a contourf.

I have also tried to copy the plynomial by hand as:

for i=1:number_of_points
    w_x_1_reconstructed(i)=-5.63591*x(i)+0.324034*x(i)^2-0.00683514*x(i)^3+0.0000485218*x(i)^4+710.999*y(i)-54.1068*x(i)*y(i)+1.47658*x(i)^2*y(i)-0.0174122*x(i)^(3)*y(i)+0.0000711661*x(i)^4*y(i)+27.2783*y(i)^2-1.79134*x(i)*y(i)^2+0.0390551*x(i)^2*y(i)^2-0.000305961*x(i)^3*y(i)^2+(4.60362*10^(-7))*x(i)^4*y(i)^2+0.372277*y(i)^3-0.0206956*x(i)*y(i)^3+0.000304779*x(i)^2*y(i)^3+(3.15853*10^(-7))*x(i)^3*y(i)^3-(2.24926*10^(-8))*x(i)^4*y(i)^3+0.00164353*y(i)^4-0.00006926*x(i)*y(i)^4+(2.79603*10^(-8))*x(i)^3*y(i)^4-(2.70495*10^(-10))*x(i)^4*y(i)^4;  
end

but the resulting figure looks nothing at all as the original f(x, y). I am attaching my .nb file in case it is helpful.

Any advice on how to proceed is appreciated. Thanks.

Attachments:
POSTED BY: Jaime de la Mota
6 Replies
Posted 6 years ago

I hope you can understand why it's hard to give you specific advice on this question and your other recent question. You mention using 3 pieces of software (Mathematica, MATLAB, and AMPL) and not an explanation as to why you need 3 pieces of software. You mention AMPL for "optimizing" a function but Mathematica certainly has several flavors of optimizing functions.

So my question to you is "Why not just use Mathematica for everything?" Without a more complete idea of what you're trying to do, it's just hard to give appropriate advice.

POSTED BY: Jim Baldwin
Posted 6 years ago

Hi Jaime,

Have you tried plotting the fit and the data points in Mathematica? Something like

Show[Plot3D[
  NLMX1R[x, y], {x, Min@XPos, Max@XPos}, {y, Min@YPos, Max@YPos}, 
  PlotRange -> All], Graphics3D[{PointSize[0.01], Point[TX1R]}]]
POSTED BY: Rohit Namjoshi

Thanks. It works fine.

POSTED BY: Jaime de la Mota
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard
Be respectful. Review our Community Guidelines to understand your role and responsibilities. Community Terms of Use