MATLAB
MATLAB
0.8
amplitude 0.6
0.4
0.2
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
samples
continous
1
0.8
0.6
amplitude
0.4
0.2
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
time
2. A= [zeros(1,500) ones(1,501)]
3. t= 0:0.01:10
4. subplot(2,1,1)
5. stem(t-5,A)
6. xlabel(' samples')
7. ylabel('amplitude')
8. title ('Discret')
9. subplot(2,1,2)
10. plot(t-5,A)
11. xlabel('time')
12. ylabel('amplitude')
13. title ('continous')
14. grid on
2. RELU Function
for i=1:1:11
if (i>=0)
A(i)=i-1;
else (i<0)
A(i)= 0;
end
end
z=[zeros(1,10), A];
i=1:1:21
subplot(2,1,1)
plot(i-11,z)
xlabel('Time')
ylabel('amplitudes')
grid on
subplot(2,1,2)
stem(i-11,z)
xlabel('Samples')
ylabel('amplitudes')
grid on
10
6
amplitudes
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
Time
10
6
amplitudes
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
Samples
3. Ramp Function
for i=1:1:10
A(i)=i-1;
end
i=1:1:10;
subplot(2,1,1)
plot(i-1,A)
xlabel('Time')
ylabel('amplitudes')
grid on
subplot(2,1,2)
stem(i-1,A)
xlabel('Samples')
ylabel('amplitudes')
grid on
10
6
amplitudes
0
0 1 2 3 4 5 6 7 8 9
Time
10
6
amplitudes
0
0 1 2 3 4 5 6 7 8 9
Samples
4. Le. RELU Function
for i=1:1:21
k=i-11
if (k>=0)
A(i)= k;
else (k<0)
A(i)= 0.1*k;
end
end
% z=[zeros(1,10), A];
i=1:1:21
subplot(2,1,1)
plot(i-11,A)
xlabel('Time')
ylabel('amplitudes')
grid on
subplot(2,1,2)
stem(i-11,A)
xlabel('Samples')
ylabel('amplitudes')
grid on
10
5
amplitudes
-5
-10 -8 -6 -4 -2 0 2 4 6 8 10
Time
10
5
amplitudes
-5
-10 -8 -6 -4 -2 0 2 4 6 8 10
Samples
5. Sawtooth wave
T=10*(1/50);
Fs=1000;
dt=1/Fs;
t=0:dt:T-dt;
x=sawtooth(2*pi*50*t);
plot(t,x);
6. Monotone Signal in audible range :
A=1;
sf=50;
Fs=40000;
Val=[0];
for f=sf:50:1000
for n=0:1:5*Fs/f
x(n+1)= A*sin(2*pi*f*n/Fs);
Val=[Val x(n+1)];
end;
end;
plot(Val);
sound= audioplayer (Val,Fs);
play (sound);