-
Notifications
You must be signed in to change notification settings - Fork 1
/
Delta_Modulation.m
51 lines (47 loc) · 1.06 KB
/
Delta_Modulation.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function [y MSE]=Delta_Modulation(del,A)
%del=step size
%A=amplitude of signal
%y=output binary sequence
%Vary del value and check when MSE is least
%If you have any problem or feedback please contact me @
%%===============================================
%NIKESH BAJAJ
%Aligarh Muslim University
%+919915522564, [email protected]
%%===============================================
Vwind=12; % wind speed at 19.4 m
dw=0.01; % the difference between successive frequencies
w=0.01:dw:4; % angular frequencies
t=0.1:0.02:500; % simulation time
x=0;
N=length(t);
el=zeros(1,N);
S=waveSpectrum(Vwind,w);
figure;
plot(S);
xlabel('frequency [rad/s]');
ylabel('wave spectrum [m^2/s]');
grid on;
%t=0:2*pi/100:2*pi;
t=0:1:100;
x=A*S;
plot(x)
hold on
y=[0];
xr=0;
length(x)
for i=1:length(x)-1
if xr(i)<=x(i)
d=1;
xr(i+1)=xr(i)+del;
else
d=0;
xr(i+1)=xr(i)-del;
end
y=[y d];
end
stairs(xr)
hold off
MSE=sum((x-xr).^2)/length(x);
MSE
end