%%%% Steps of numeric double integration
%%%% Analytic method
clear;clc;clf reset;warning off MATLAB:divideByZero;close all
sitil = ['-k  ';'--k ';':k  ';'-.k ';'-xb ';'-om ';'--om';':om ';'-.om';'-*g ';'-.xk'];
syms ta t T A
y12 = A*sqrt(3/T)*int((2*ta/T - 1)*(2*(T - t + ta)/T - 1),ta,0,t);
y13 = A*sqrt(3/T)*int((2*ta/T - 1)*(2*(T - t + ta)/T - 1),ta,t-T,T);
y12i = simplify(y12);pretty(y12);
simplify(y13);pretty(y13);
t = T;y12e = eval(y12i);simplify(y12e) %pretty(y12i)
% y12 = int((2*ta/T - 1)*1,ta,0,t)
% y13 = int((2*ta/T - 1)*1,ta,t-T,T)
% T = 1;t = 0:0.01:1;y1t = eval(y12);  
% t = 1:0.01:2;y2t = eval(y13);
% y1 = [y1t y2t];t = [0:0.01:1 1:0.01:2];
% figure(1)
% subplot(3,1,3);plot(t,y1,sitil(1,:),'LineWidth',2.5);
% axis ([-1.2 2.0 min(y1)*1.1 max(y1)*1.1]);
% set(gcf,'Renderer','Zbuffer');set(gcf,'Color','White');set(gca,'FontSize',18);axis off
% figure(2)
% plot(t,y1)
% %%%% For Q1 of April 2015
% figure(2)
% t = 0:100;T = 100;y = -sin(pi*t/T);
% plot(t,y,sitil(1,:),'LineWidth',2.5);
% set(gcf,'Renderer','Zbuffer');set(gcf,'Color','White');set(gca,'FontSize',18);axis off