%%  This is an example of creating and plotting data.
%%  In this script we control the plot and its look (fonts, colors, etc)


clear;
figure(1);
clf;

%% create a grid from -1 to 1
x = linspace(1,-1,100)';

%% Create the first four chebyshev polynomials
%% Store in a matrix
T(:,1) = ones(size(x));
T(:,2) = x;
T(:,3) = 2*x.*T(:,2) - T(:,1);
T(:,4) = 2*x.*T(:,3) - T(:,2);

%% Plot each column a different color
color = 'brkg';
for i = 1:4
  plot(x,T(:,i),color(i),'LineWidth',1)
  hold on
end

axis([ -1 1 -1.1 1.1]); %% set the axis
grid on                 %% add grid lines

%% Set the axis, a legend, and control the fonts
set(gca,'FontSize',12,'FontName','times')
xlabel('x')
ylabel('T(x)')
h = legend('T_1', 'T_2', 'T_3', 'T_4','Location', ...
	   'NorthEastOutside');
set(h,'FontSize',14)
