% demostración gráfica de la formula de euler

A = 1;
f = 1;
t_points=100;
t = linspace(0,1,t_points+1);
t = t(1:end-1);

figure(1);
subplot(121);hold off;

pos_seq=plot(0,0,'r.-');grid on;hold on;
neg_seq=plot(0,0,'b.-');
axis([-A/2*1.1 A/2*1.1 -A/2*1.1 A/2*1.1]);
axis equal;

subplot(122);
total_seq=plot(-1,0,'b.-');grid on;
axis([0 t(end) -A*1.1 A*1.1]);

set(gcf,'Color',[1 1 1],'Position',[298   444   887   231]);

for cc=1:t_points
    pos_seq_data=A/2*exp(j*2*pi*f*t(1:cc));
    neg_seq_data=A/2*exp(-j*2*pi*f*t(1:cc));
    set(pos_seq,'XData',real(pos_seq_data),'YData',imag(pos_seq_data));
    set(neg_seq,'XData',0.97*real(neg_seq_data),'YData',0.97*imag(neg_seq_data));
    
    set(total_seq,'XData',t(1:cc),'YData',pos_seq_data+neg_seq_data);
    drawnow;
    pause(0.1);
end
