%Always clear variables and close eplots
clear all
close all

%Make plots look nicer...
set(0,'DefaultLineLineWidth',3)
set(0,'DefaultAxesFontSize',20)
set(0,'DefaultTextFontSize',20)

%Suppose we want to compute Y vs t and X vs r for varous values...
Nt = 10;
Nr = 100;

t = logspace(0,1,Nt); %Distribute t linearly from 1 to 10
r = linspace(1,100,Nr);%Distribute r linearly from 1 to 100

%Best to define arrays before you use them...
Z = zeros(10,100);

Y = t.^2;% Notice the use of the point notation for vector multiplication
X = j*sin(1./r); %and division. 
                 %i or j = sqrt(-1): so do not use as an array index.
		    
%Use for loops (the lazy but easy way)
for tcounter=1:Nt
  for rcounter = 1:Nr

  Z(tcounter,rcounter) = sin(Y(tcounter)) + X(rcounter);

end
%Do some logy plots in sequence
semilogy(r, abs(Z(tcounter,:)),'k')
hold on %Keep the graph up
end
title('Matlab Demo')
xlabel('X values')
ylabel('Y values')
axis([0 80 0 1])%Set the axes 
hold off

