function m = tof(flip,tr,ntr,t1);

% function [ma mb] = tof(flip,tr,ntr,t1);
% does a simple calculation of spgr signal vs pulse number starting from relaxed magnetization
% flip can be a vector

ca = cos(flip*pi/180.)';
et1 = exp(-tr/t1);
nflip = prod(size(flip));

m = ones(nflip,ntr);
for k=2:ntr
	m(:,k) = 1-((1-m(:,k-1).*ca)*et1);
end;
m = m .* repmat(sin(flip*pi/180.)',1,ntr);

figure;
plot(0.001*tr*(1:ntr),m');
