From: Andreas on
Hi,

I have a simple question regarding sftool.
I try to get started with a simple test example such that:

x=-2:.2:2;
y= -2:.2:2;
[X,Y] = meshgrid(x, y);
Z = X .* exp(-X.^2 - Y.^2);
surf(X,Y,Z);
sftool(x,y,Z);

However, this gives an error saying "Invalid inputs to SFTOOL, input vectors must be double. Z-data is invalid."

I am not sure if I understand the logic of this program right but it does not make sense to me that Z (the surface to be fitted) should be a vector and not a matrix...

Can anyone help me out on this.

Andreas
From: Steven Lord on

"Andreas " <andreasm(a)atmos.washington.edu> wrote in message
news:hb29lh$etb$1(a)fred.mathworks.com...
> Hi,
>
> I have a simple question regarding sftool.
> I try to get started with a simple test example such that:
>
> x=-2:.2:2;
> y= -2:.2:2;
> [X,Y] = meshgrid(x, y);
> Z = X .* exp(-X.^2 - Y.^2);
> surf(X,Y,Z);
> sftool(x,y,Z);
>
> However, this gives an error saying "Invalid inputs to SFTOOL, input
> vectors must be double. Z-data is invalid."
>
> I am not sure if I understand the logic of this program right but it does
> not make sense to me that Z (the surface to be fitted) should be a vector
> and not a matrix...

Why not? That's what the documentation indicates SFTOOL expects.

http://www.mathworks.com/access/helpdesk/help/toolbox/curvefit/sftool.html

"sftool(x,y,z) creates a fit to x and y inputs (or predictor data) and z
output (or response data). x, y, and z must be double vectors of the same
length, with two or more elements. sftool opens Surface Fitting Tool if
necessary."

Use the following command instead of your last one above:

sftool(X(:), Y(:), Z(:))

This makes all three inputs double vectors of the same length, which is what
SFTOOL expects.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Andreas on
"Steven Lord" <slord(a)mathworks.com> wrote in message <hb2cgg$lav$1(a)fred.mathworks.com>...
>
> "Andreas " <andreasm(a)atmos.washington.edu> wrote in message
> news:hb29lh$etb$1(a)fred.mathworks.com...
> > Hi,
> >
> > I have a simple question regarding sftool.
> > I try to get started with a simple test example such that:
> >
> > x=-2:.2:2;
> > y= -2:.2:2;
> > [X,Y] = meshgrid(x, y);
> > Z = X .* exp(-X.^2 - Y.^2);
> > surf(X,Y,Z);
> > sftool(x,y,Z);
> >
> > However, this gives an error saying "Invalid inputs to SFTOOL, input
> > vectors must be double. Z-data is invalid."
> >
> > I am not sure if I understand the logic of this program right but it does
> > not make sense to me that Z (the surface to be fitted) should be a vector
> > and not a matrix...
>
> Why not? That's what the documentation indicates SFTOOL expects.
>
> http://www.mathworks.com/access/helpdesk/help/toolbox/curvefit/sftool.html
>
> "sftool(x,y,z) creates a fit to x and y inputs (or predictor data) and z
> output (or response data). x, y, and z must be double vectors of the same
> length, with two or more elements. sftool opens Surface Fitting Tool if
> necessary."
>
> Use the following command instead of your last one above:
>
> sftool(X(:), Y(:), Z(:))
>
> This makes all three inputs double vectors of the same length, which is what
> SFTOOL expects.
>
> --

O.k., I figured it out. Thanks.
I have another more advanced question:
I want to exclude some of my data from the fitting procedure. There exist a simple way of doing this in the cftool but I could not find this option in the sftool and the documentation doen't say about this as far as I can see. So, how would that work?
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
From: Steven Lord on

"Andreas " <andreasm(a)atmos.washington.edu> wrote in message
news:hb2kck$g79$1(a)fred.mathworks.com...

*snip*

> O.k., I figured it out. Thanks.
> I have another more advanced question:
> I want to exclude some of my data from the fitting procedure. There exist
> a simple way of doing this in the cftool but I could not find this option
> in the sftool and the documentation doen't say about this as far as I can
> see. So, how would that work?

You could use the Exclude Outliers tool:

http://www.mathworks.com/access/helpdesk/help/toolbox/curvefit/brviv3f-1.html#brybu6k-1

or filter out the points you want to exclude from your vectors and import
the shortened vectors into SFTOOL, or perhaps just set the weights for those
excluded points to 0.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ