% % Problem Epage 200 % Example 5.23 Epage 173 % % Written by: % -- % John L. Weatherwax 2008-02-20 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- clear all; close all; clc; addpath('../../Code/CSTool'); load iris; % <- three matrics setosa/versicolor/virginica of size [n,p] % define the plotting domain: theta = (-pi+eps):0.1:(pi-eps); n = 50; % <- the number of samples of each type of flower p = 4; % <- the number of features yvirginica = zeros(n,p); yversicolor = zeros(n,p); % compute the dot product of our trig function with each sample's component: % ang = zeros(length(theta),p); % <- space to hold angle x feature fstr = '[1/sqrt(2) sin(i) cos(i) sin(2*i)]'; k=1; % evaluate sin/cos at each angle: for i=theta, ang(k,:) = eval(fstr); k=k+1; end % now take the dot product producing a function for each observation: for i=1:n, for j=1:length(theta), % find dot product: yvirginica(i,j) = virginica(i,:)*ang(j,:)'; yversicolor(i,j) = versicolor(i,:)*ang(j,:)'; end end % do all plots: plot(theta,yvirginica(1,:),'r',theta,yversicolor(1,:),'b-.'); hold on; legend('Iris virginica','Iris versicolor'); for i=2:n, plot(theta,yvirginica(i,:),'r',theta,yversicolor(i,:),'b-.'); end title( 'Andrews Plot' ); xlabel('t'); ylabel('Andrews Curve'); grid on; saveas( gcf, 'andrews_virg_vers', 'epsc' );