%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Nick Sitarski
%Vladi Gergov
%ECE 317
%Winter 2003
%Professor Awad
%Lab #2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Problem 1
t=[0:.1:15];
x1=2*exp(-t);
x2=sin(t+pi/4);
x=1-x1.*x2;
figure(1),plot(t,x),grid on
xlabel('Time In Sec');
ylabel('Amplitude');
title('Decaying Sine Wave');


%Problem 2
v=[0,16,-1,2];
t=[0:.05:25]';
y1=1.25*exp(-t);
y2=2.02*exp(-.3*t)
figure(2),plot(t,[y1,y2]),grid on,legend('1.25e^-t','2.02e^-.3t');
xlabel('Time In Sec');
ylabel('Amplitude');
title('Problem 2 Part A');
axis(v);
figure(3),subplot(2,1,1),plot(t,y1),grid on;
xlabel('Time In Sec');
ylabel('Amplitude');
title('Problem 2 Part B');
axis(v);
figure(3),subplot(2,1,2),plot(t,y2),grid on;
xlabel('Time In Sec');
ylabel('Amplitude');
title('Problem 2 Part B');
axis(v);
y2(1,1)
y2(91,1)
y2(241,1)

%Problem 3
t=[-5:.01:5]';
x1=2*t;
x2=.25+t.^2;
y=x1./x2;
figure(4),subplot(3,1,1),plot(t,y),grid on;
xlabel('Time In Sec');
ylabel('Amplitude');
title('Y(t)');
figure(4),subplot(3,1,2),plot(-t,y),grid on;
xlabel('Time In Sec');
ylabel('Amplitude');
title('Y(-t)');
figure(4),subplot(3,1,3),plot(t,-y),grid on;
xlabel('Time In Sec');
ylabel('Amplitude');
title('-Y(t)');
%By the graphs the function is odd 
min(y) 
max(y) 
solve('2=(2*x)/(.25+x^2)')
solve('-2=(2*x)/(.25+x^2)')

%Problem 4
x1=[-.5:.01:1]';
y1=sin(pi*x1);
x2=[1:.01:3]';
y2=x2-1;
x3=[3:.01:5]';
y3=-2*x3+8;
figure(5),plot(x1,y1,x2,y2,'--',x3,y3),grid on;
xlabel('Time In Sec');
ylabel('Amplitude');
title('Piece Function');

%Problem 5
x=[-5:.01:5]';
v=[-1,3,-1,2];
y1=2.*exp(-x.^2);
y2=(x-1).^2-2;
figure(6),plot(t,[y1,y2]),grid on,legend('2e^(-x^),(x-1)^2-2');
xlabel('Time In Sec');
ylabel('Amplitude');
title('Piece Function');
figure(7),plot(t,[y1,y2]),grid on,legend('2e^(-x^),(x-1)^2-2');
xlabel('Time In Sec');
ylabel('Amplitude');
title('Piece Function');
axis(v);
[xp,yp]=ginput(2)









