% crash_ghostscript.m                              Steve Mann,  1991
%
% CORE DUMPS GHOSTSCRIPT by having 2 functions on same matlab subplot
%
% GhostScript crashes if
%    200 subplot(221) plot with dotted line, and 200 or more points
% Does not crash if:
%    not subplot (eg. 10000 pts dotted line o.k.)
%    100 pts or less
%    solid line of any length (eg. 10000 pts solid line in a subplot(221) o.k.)

L = 400;  % length of signal vector
          % 100 points o.k.
          % 200 samples crashes gs

t  = linspace(-.5,.5,L).';   % time index goes -1/2 to 1/2
fc = 3; % fixed carrier freq (fc=3 means 3 cycles of sine wave over whole time)
s  = exp(i*2*pi*fc*t);

clg
hold off
axis('normal') % rectangular

%subplot  % with no subplots, ghostscript o.k.
subplot(221) % ghostscript crashes with subplots with more
axis([-.5 .5 -1 1]) % reduce editing work half, usual get both .5 , 1
plot(t,real(s)*.9,':')  % want it not to quite touch limits

%hold on       % with 2 functions on same subplot, gs crashes
%  plot(t,abs(s)*.9,':')   % dotted line crashes gs
%  plot(t,abs(s)*.9)      % solid line doesnt crash gs
%hold off

title('real(s(t))')
%xlabel('Time')
%ylabel('Amplitude')

delete deleteme.met
disp('deleted deleteme.met')
meta deleteme
!gpp -dps deleteme
!gs deleteme.ps

