On 4=E6=9C=889=E6=97=A5, =E4=B8=8B=E5=8D=889=E6=97=B649=E5=88=86, "Steven L=
ord" <sl...@mathworks.com> wrote:
> "mango" <sniperhunt...@gmail.com> wrote in message
>
> news:75a53998b9fd4d15b24b4775a39c89bd@k8g2000yqn.googlegroups.com...
> On 4=C3=94=C3=829=C3=88=C3=95, =C3=8F=C3=82=C3=8E=C3=A72=C3=8A=C2=B111=C2=
=B7=C3=96, "Roger Stafford"
>
>
>
>
>
> <ellieandrogerxy...@mindspring.com.invalid> wrote:
> > mango <sniperhunt...@gmail.com> wrote in message
> > <4b464a96bf2649fe82ecdd821145c...@z9g2000yqi.googlegroups.com>...
> > > Hi, All.
> > > =C2=A0 I've got a problem like this:
> > > =C2=A0 =C2=A0 =C2=A0 input some insturctions like
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 syms x y
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 min(x,y)
> > > =C2=A0 =C2=A0in the workspace.Then get the following error :
>
> > > ??? Function 'min' is not defined for values of class 'sym'.
>
> > > Error in =3D=3D> min at 34
> > > =C2=A0 builtin('min', varargin{:});
>
> > > In the other side, I try to use abs function like this,
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 syms x
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 abs(x)
> > > Then get the correct answer.How to solve this probelm?
>
> > > pls help me ,thank you in advance.
>
> > =C2=A0 Think about it, Mango. =C2=A0What answer can you expect out of m=
in(x,y) when
> > x and y are merely symbols whose values cannot be compared numerically.
> > Matlab could answer: "Duh! Ya got me!" but I don't think users would li=
ke
> > that very much. =C2=A0Much better to respond with an error indication.
>
> > Roger Stafford =C3=92=C3=BE=C2=B2=C3=98=C2=B1=C2=BB=C3=92=C3=BD=C3=93=
=C3=83=C3=8E=C3=84=C3=97=C3=96 
>
> >  =C3=8F=C3=94=C3=8A=C2=BE=C3=92=C3=BD=C3=93=C3=83=C2=B5=C3=84=C3=8E=C3=
=84=C3=97=C3=96 
>
> > Dear Roger, thanks for your answer,
>
> > I just want to use 'min' function to produce a kernel function, like a
> > spline function:
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A01 =
+ x*y + 1/2*xy*(x/\y)^2 + 1/3*(x/\y)^3
> > Here 'x/\y' means min(x,y).
> > In matlab, I define an anonymous function like this,
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fu=
n =3D @(x,y) (1 + x * y + 1/2 * abs(xy)*min(x,y)^2
> > + 1/3 * min(x,y)^3)
> > Then I define a 'sym' variouble x to calculate it(here 'y' is a
> > constant).And get the error like that
> > " ??? Function 'min' is not defined for values of class 'sym' ".
>
> > I've understood your meaning that 'min(x,y)' can't use in 'sym'
> > because they are symbols, but now I wanna to =C2=A0calculate the functi=
on.
> > Can any other functions or instruments take the similar operation like
> > 'min()' in my situation.
>
> Evaluate the anonymous function you created for numeric values of x and y=
.
>
> x =3D 5;
> y =3D 6;
> fun(x, y)
>
> If you vectorize your anonymous function (using .* and .^ instead of * an=
d
> ^) you can even call it with a vector or matrix of x and y values.
>
> fun =3D @(x, y) (1+x.*y + 1/2*abs(xy).*min(x, y).^2 + 1/3*min(x, y).^3);
> x =3D 1:10;
> y =3D 1:10;
> fun(x, y)
>
> I didn't use .* when multiplying 1/2 and 1/3 by the rest of the term beca=
use
> 1/2 and 1/3 are scalars, and * and .* do the same thing when one of their
> inputs are scalar.
>
> 
> Steve Lord
> sl...@mathworks.com =E9=9A=90=E8=97=8F=E8=A2=AB=E5=BC=95=E7=94=A8=E6=96=
=87=E5=AD=97 
>
>  =E6=98=BE=E7=A4=BA=E5=BC=95=E7=94=A8=E7=9A=84=E6=96=87=E5=AD=97 
Thank you for your answer. Now I have managed to solve my problem. And
I do use '.*' and '.^' for vector calculation. But I gave up my
original thoughts about define 'sym' variable.
