// Plot Quad plots the conic section for a given 2x2 symmetric matrix // It assumes that the matrix is A and it is already defined. // It plots black curves theta = 0:%pi/50:2*%pi; // %pi is scilab for the constant pi n = size(theta,2); // theta is a 1 x n row vector x = zeros(theta); // x and y start as zero vectors y = zeros(theta); for i = 1:n, angle = theta(i); // this angle c = cos(angle); s = sin(angle); X = [ c, s ]; r = sqrt(1/abs(X*A*X')); // formula from section 4 x(i) = r*c; // r cos(theta) y(i) = r*s; end; plot(x,y,'k-'); a = gca(); a.isoview="on"; title="Conic for A = ["+string(A(1,1))+" "+string(A(1,2)) +"; "+string(A(2,1))+" "+string(A(2,2))+"]"; xtitle(title,"x","y");