h = animatedline('Marker','o'); x = 1:5; y = 1:5; addpoints(h,x,y) |
h = animatedline; axis([0 4*pi -1 1]) x = linspace(0,4*pi,2000); for k = 1:length(x) y = sin(x(k)); addpoints(h,x(k),y); drawnow end |
h = animatedline; axis([0 4*pi -1 1]) x = linspace(0,4*pi,2000); for k = 1:length(x) y = sin(x(k)); addpoints(h,x(k),y); drawnow limitrate end drawnow |
a1 = animatedline('Color',[0 .7 .7]); a2 = animatedline('Color',[0 .5 .5]); axis([0 20 -1 1]) x = linspace(0,20,10000); for k = 1:length(x); % first line xk = x(k); ysin = sin(xk); addpoints(a1,xk,ysin); % second line ycos = cos(xk); addpoints(a2,xk,ycos); % update screen drawnow limitrate end |
F = getframe F(i) = getframe |
plot(rand(5)) F = getframe; imshow(F.cdata) |
Z = peaks; figure('Renderer','zbuffer'); surf(Z); axis tight; set(gca,'NextPlot','replaceChildren'); for j = 1:20 surf(sin(2*pi*j/20)*Z,Z) F(j) = getframe; end disp('now to the movie') movie(F,20) % Play the movie twenty times |
movie(M) |
figure Z = peaks; surf(Z) axis tight manual ax = gca; ax.NextPlot = 'replaceChildren'; loops = 40; F(loops) = struct('cdata',[],'colormap',[]); for j = 1:loops X = sin(j*pi/10)*Z; surf(X,Z) drawnow F(j) = getframe; end % play movie twice movie(F,2) |
v = VideoReader(filename) |
v = VideoReader('xylophone.mp4'); while hasFrame(v) video = readFrame(v); end whos video v.CurrentTime = 2.5; currAxes = axes; while hasFrame(v) vidFrame = readFrame(v); image(vidFrame, 'Parent', currAxes); currAxes.Visible = 'off'; pause(1/v.FrameRate); end |
v = VideoWriter('peaks.avi'); open(v); Z = peaks; surf(Z); axis tight manual set(gca,'nextplot','replacechildren'); for k = 1:20 surf(sin(2*pi*k/20)*Z,Z) frame = getframe; writeVideo(v,frame); end close(v); |
x=0:10:360; y=sind(x); theta=0; while 1 theta=theta+1; y_plot=y*sind(theta); plot(x,y_plot); axis([0,360,-1.2,1.2]); pause(0.001); end |
x=linspace(0,1,100); [X,Y] = meshgrid(x,x); N=100; % Number of frames for i = 1:N % Example of plot Z = sin(2*pi*(X-i/N)).*sin(2*pi*(Y-i/N)); surf(X,Y,Z) % Store the frame M(i)=getframe(gcf); % leaving gcf out crops the frame in the movie. end movie(M) |
% Draw a sphere sphere % Make the current axis box square in size axis('square') % Define title and labels for reference title('Rotation of a sphere...') xlabel('x'); ylabel('y'); zlabel('z') % Modify azimuth (horizontal rotation) and update drawing for az = -50 : .2 : 30 view(az, 40) drawnow end % Modify elevation (vertical rotation) and update drawing for el = 40 : -.2 : -30 view(30, el) drawnow end |
% Define paraboloid X = -2 : .1 : 2; Y = X; [x, y] = meshgrid(X, Y); z = .5 * (x.^2 + y.^2); % Draw 3D figure, keep track of its handle h = surf(x,y,z); % Keep axes constant axis([-2 2 -2 2 0 20]) % Define title and labels for reference xlabel('x'); ylabel('y'); zlabel('z') % Stretch paraboloid and show updates for i = 1 : .1 : 5; set(h, 'xdata', x, 'ydata', y, 'zdata', i*z) drawnow pause(.1) end % Modify azimuth (horizontal rotation) and update drawing for az = -37.5 : .5 : 30 view(az, 30) drawnow end |
"It's a time of sorrow and sadness when we lose a loss of life." |
"Milosevic has barely begun to incur the damage he will feel." |
Delighting in sacrifice
In an instant-on, one-click shopping universe, the idea of sacrifice is pretty alien. When the world might end tomorrow, when you can get what you want now, when debt is easier than ever to go into, why even consider sacrifice?
Because it's the single best way to achieve your goals. Satisfaction now almost always decreases the reserves we have to build an asset for later. Investing in something worth building always requires you to avoid getting what you want today. Sacrifice might mean giving up an expenditure, but it can also be the bold step of having a difficult conversation now instead of later.
Regardless of the goal, sacrifices make it more likely that you'll get there.
The journey toward that worthy goal, though, is a key part of the goal itself. We are never certain we'll reach our goal, one significant reason that so few people persist. But if the journey involves sacrifice, we're paying for that goal, the goal we're never sure to reach, every day.
Hence delight.
The act of sacrifice, of foregoing one thing in our journey toward another one, one more generous, virtuous and useful, is actually a little piece of the satisfaction of the goal itself.
If it comes easy, it's not the same.