|
Hallo Tom,
Your help solved my problem. Thank You very much.
Thomas
"Tom Lane" <tlane@mathworks.com> wrote in message <hcnodi$aob$1@fred.mathworks.com>...
> > I have data similar to that of the fisheriris data in the classification
> > demo
> . . .
> > How would I extend the formula for 3 variables ? It seems that the order
> > of the coefficients provided by classify is not further documented in
> > detail.
>
> Thomas, the example picks apart the coefficient arrays into separate scalars
> so they can be conveniently used in a two-dimensional example. The intent is
> that the coefficients are documented using the following matrix-oriented
> expression given in the help:
>
> 0 < K + x*L + x*Q*x'
>
> To plot this, the isosurface function may be useful. I don't know of an
> easier way. Try this:
>
> % Get 3 measurements from 2 iris species
> load fisheriris
> rows = 51:150;
> X = meas(rows,1:3);
> x = X(:,1); y = X(:,2); z = X(:,3);
> s = species(rows);
> a = 1:50; b = 51:100;
>
> % Do quadratic classification and get coefficients of boundary
> [c,err,post,logl,str] = classify(X,X,s,'quadratic');
> K = str(1,2).const;
> L = str(1,2).linear;
> Q = str(1,2).quadratic;
>
> % Plot the data and curve K + [x,y,z]*L + [x,y,z]*Q*[x,y,z]' = 0:
> xv = linspace(4.5,8,10); % vectors to cover the range of each column
> yv = linspace(2,4,10);
> zv = linspace(2.5,7,10);
> [xx,yy,zz] = meshgrid(xv,yv,zv);
> f = @(x,y,z) K + [x y z]*L + sum([x y z] .* ([x y z]*Q), 2);
> v = f(xx(:),yy(:),zz(:));
> v = reshape(v,size(xx));
> plot3(x(a),y(a),z(a),'rv', x(b),y(b),z(b),'b^');
> hold on
> isosurface(xx,yy,zz,v,0);
> hold off
>
> -- Tom
>
|