% % Written by: % -- % John L. Weatherwax 2007-07-01 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- close all; clc; clear; mu1 = [ 0.1, 0.1 ].'; mu2 = [ 2.1, 1.9 ].'; mu3 = [ -1.5, 2.0 ].'; S = [ [ 1.2, 0.4 ]; [ 0.4, 1.8 ] ]; w1 = S \ mu1; w2 = S \ mu2; w3 = S \ mu3; P = 1/3; w10 = log(1/3) - 0.5 * (mu1.') * w1; w20 = log(1/3) - 0.5 * (mu2.') * w2; w30 = log(1/3) - 0.5 * (mu3.') * w3; x = [ 2.1; 1.9 ]; % Compute the three discriminant values: % g1 = (w1.')*x + w10; g2 = (w2.')*x + w20; g3 = (w3.')*x + w30; [m, class] = max( [g1, g2, g3] );