[11954] in Athena Bugs
decmips 7.6G: matlab 4.1
daemon@ATHENA.MIT.EDU (kyang@MIT.EDU)
Wed Apr 13 15:38:54 1994
From: kyang@MIT.EDU
To: bugs@MIT.EDU
Date: Wed, 13 Apr 94 15:38:40 EDT
System name: m37-312-15
Type and version: KN01 7.6G
Display type: PMAX-MFB
What were you trying to do?
Produce a plot of some intersecting ellipses. The ellipses
are all centered on (0,0). The program below automatically
plots the ellipses.
Matlab 3.5 does it correctly. Matlab 4.1 does not.
Run the program on both. See what happens.
What's wrong:
Matlab 4.1 puts extraneous horizontal lines inside the square shaped
area of [-.75 .75 -.75 .75]. This area is actually free of any data
lines.
Matlab 4.1 does the correct thing for 'axis' sizes of about
[-5 5 -5 5] or larger. Below this size, the extra lines appear.
Run the program on matlab 3.5 and see that the area should
be free of lines.
Alternatively, from Matlab 4.1, uncomment the 3rd from last line
in the program to enable the 'pause' command. Then comment out the
'hold on' command directly below that. This will allow you to
see each ellipse appear individually. You will see that there are
no lines drawn in the verboten region. The extra lines only appear
when all the ellipses are drawn, and the axes are scaled to a small
value.
What should have happened:
It should look like the matlab 3.5 output. An open square.
Please describe any relevant documentation references:
Here is my .m file which you are free to use and distribute
as you like.
Please, please retain Matlab 3.5 beyond June. Very often
Matlab 4 is too bugy to be useful!!!!!
---------------------------------------------------------
% 16.982, ps#4, problem 2.
% Kyle Yang 4/13/94
hold off; clg
alp=0.1
A=[-1 alp
0 -1];
Bw=eye(2);
%... stuff to draw circles
dt=100
thet=[0:2*pi/dt:2*pi];
x=cos(thet); y=sin(thet);
%... search of all possible Lagrange mult matrices, R.
% For each R, solve a Lyapunov equn.
rmin=.000001
rmax=1-rmin;
dr=10
rvec=[rmin:(rmax-rmin)/dr:rmax];
for i=1:length(rvec)
R=[rvec(i) 0
0 rvec(length(rvec)-i+1)];
Q=lyap(A,Bw/R*Bw');
% Plot the ellipse given by P=inv(Q)
% note: it's in 2-space
[Vq,lamq]=eig(Q);
% rotation amount
phi=atan2(Vq(2,1),Vq(1,1));
Rot=[cos(phi) sin(phi)
-sin(phi) cos(phi)];
Rot*[x;y];
xnew=ans(1,:);
ynew=ans(2,:);
%
% magnitude is scaled by the eigenvals of P, which are inv of evals of Q
axis([-1 1 -1 1])
plot(sqrt(lamq(1,1))*xnew,sqrt(lamq(2,2))*ynew)
% pause
hold on
end