% Exercícios sobre:
% Transformações na variável independente
% Notas de aula SDL: Cap. 1


clear all;
close all;
clc;
t=-10:0.0001:10;
x = inline('((t>=-1)&(t<=0))+t.*((t>0)&(t<1))+((t>=1)&(t<=2))','t');


%% Exemplo página 30 das notas de aula do Cap. 1
figure(1)
subplot(2,1,1)
plot(t,x(t),'LineWidth', 2);
box off;
axis([-2 3 0 1.5]);
xlabel('t (tempo)')
ylabel('x(t)')
title('Exemplo pág. 30 Cap. 1')
grid;


figure(1)
subplot(2,1,2)
title('Presione uma tecla para ver o resultado')
pause;
plot(t,x(1-t/2),'LineWidth', 2);
axis([-3 5 0 1.5]);
xlabel('t (tempo)')
ylabel('x(1-t/2)')
title('Solucao')
grid;
pause;

%% Exercício página 34 das notas de aula do Cap. 1

figure(2)
subplot(2,1,1)
plot(t,x(t),'LineWidth', 2);
box off;
axis([-2 3 0 1.5]);
xlabel('t (tempo)')
ylabel('x(t)')
title('Exercício pág. 34 Cap. 1')
grid;

figure(2)
subplot(2,1,2)
title('Presione uma tecla para ver o resultado')
pause;
plot(t,x(2*t-1),'LineWidth', 2);
axis([-3 5 0 1.5]);
xlabel('t (tempo)')
ylabel('x(2t-1)')
title('Solução')
grid;
pause;

%% Exercício página 35 das notas de aula do Cap. 1

figure(3)
subplot(2,1,1)
plot(t,x(t),'LineWidth', 2);
box off;
axis([-2 3 0 1.5]);
xlabel('t (tempo)')
ylabel('x(t)')
title('Exercício pág. 35 Cap. 1')
grid;

figure(3)
subplot(2,1,2)
title('Presione uma tecla para ver o resultado')
pause;
plot(t,x(t),'LineWidth', 2);
subplot(2,1,2)
plot(t,3*x(2*t-1)-2,'LineWidth', 2);
axis([-3 5 -2 1.5]);
xlabel('t (tempo)')
ylabel('3x(2t-1)-2')
grid;
pause;

%% Exercício página 43 das notas de aula do Cap. 1

% Parte par
figure(4)
subplot(2,1,1)
plot(t,x(t),'LineWidth', 2);
box off;
axis([-3 3 0 1.5]);
xlabel('t (tempo)')
ylabel('x(t)')
title('Exercício pág. 43 Cap. 1')
grid;

figure(4)
subplot(2,1,2)
title('Presione uma tecla para ver a parte par')
pause;
plot(t,x(t),'LineWidth', 2);
subplot(2,1,2)
plot(t,1/2*(x(t)+x(-t)),'LineWidth', 2);
axis([-3 3 -0 1.5]);
xlabel('t (tempo)')
ylabel('x_p(t)')
grid;
pause

% Parte ímpar
figure(5)
subplot(2,1,1)
plot(t,x(t),'LineWidth', 2);
box off;
axis([-3 3 0 1.5]);
xlabel('t (tempo)')
ylabel('x(t)')
title('Exercício pág. 43 Cap. 1')
grid;

figure(5)
subplot(2,1,2)
title('Presione uma tecla para ver a parte ímpar')
pause;
plot(t,x(t),'LineWidth', 2);
subplot(2,1,2)
plot(t,1/2*(x(t)-x(-t)),'LineWidth', 2);
axis([-3 3 -1 1]);
xlabel('t (tempo)')
ylabel('x_i(t)')
grid;

