In [36]:
t = [0:0.01:0.98];
y1 = sin(2 * pi * 4 * t);

In [37]:
plot(t, y1)



In [38]:
y2 = cos(2 * pi * 4 * t);

In [39]:
plot(t, y2)



In [40]:
plot(t, y1);
hold on;
plot(t, y2, 'r');  % r in red colour
xlabel('time')
ylabel('value')
legend('sin', 'cos')
title('my plot')
print -dpng 'myplot.png'



In [41]:
% close % close down the plot

In [42]:
figure(1); plot(t, y1)
figure(2); plot(t, y2)



In [43]:
subplot(1,2,1); % Divides plot in a 1x2 grid and access first element
plot(t, y1)
subplot(1,2,2);  % second element
plot(t, y2)
axis([0.5 1 -1 1])  % set xrange and yrange



In [44]:
% clf % clear figure

In [45]:
A = magic(5)


A =

   17   24    1    8   15
   23    5    7   14   16
    4    6   13   20   22
   10   12   19   21    3
   11   18   25    2    9


In [46]:
imagesc(A)  % Plots as grid of colours



In [47]:
imagesc(A); colorbar; colormap gray;  % Changes colour map and adds in an index bar



In [48]:
imagesc(magic(15)), colorbar, colormap gray;



In [49]:
a=1, b=2, c=3  % comma chaining with output


a =  1
b =  2
c =  3

In [50]:
a=1; b=2; c=3;  % comma chaining without output