X = -5*pi:0.05:5*pi;
Y = sin(X)./X;
figure(1)
clf
plot(X,Y,'b-','LineWidth',1)
hold on
ylabel('sin(x)/x')
xlabel('0 \leq x \leq 5\pi')
title('Halfway to a mexican hat')
axis([0 5*pi -0.3 1.1])
h1 = figure(1);
h2 = get(h1,'CurrentAxes');
% Note: edit these numbers to change position
% and size of inset plot
h3 = axes('pos',[.575 .575 .31 .31]);
plot(X,Y,'b-')
xlabel('-5\pi \leq x \leq 5\pi')
axis([-5*pi 5*pi -0.3 1.1])When you run this, you get the following extremely sexy plot:Full disclosure: I copied this code from somewhere else a while ago, but I can't remember where. (Cool story, huh?) Anyway, thought I'd post it here, in case it is useful to someone.

No comments:
Post a Comment