You are on page 1of 1

a1 = str2double(get(handles.

edit1,'string'));
t1 = str2double(get(handles.edit2,'string'));
n1 = str2double(get(handles.edit5,'string'));
a2 = str2double(get(handles.edit3,'string'));
t2 = str2double(get(handles.edit4,'string'));
n2 = str2double(get(handles.edit6,'string'));

fs = 20/t1;

t = 0:1/fs:1000*t1;

g1 = a1*sin(pi*(1/t1)*t);

g2 = a2*square(t,45);

r = g1+g2;

n = 2048;
frec = fs/n*(1:n/2);

G1 = abs(fft(g1,n));
G2 = abs(fft(g2,n));
R = abs(fft(r,n));

axes(handles.axes1)
plot(t,g1,'r')
grid on
axis([0 (2/3)*n1*t1 -a1-1 a1+1])

axes(handles.axes2)
plot(t,g2,'m')
grid on
axis([0 (2/3)*n2*t2 -a2-1 a2+1])

axes(handles.axes3)
plot(t,r)
grid on
axis([0 (n2)*t2 -a1*a2 a1*a2])

axes(handles.axes4)
plot(frec,G1(1:n/2))
grid on

axes(handles.axes5)
plot(frec,G2(1:n/2))
grid on

axes(handles.axes6)
plot(frec,R(1:n/2))
grid on

You might also like