diff -r 6b7d434d0e90 inst/amdemod.m --- a/inst/amdemod.m Wed Apr 27 17:54:24 2022 -0400 +++ b/inst/amdemod.m Mon Sep 12 17:38:09 2022 +0000 @@ -50,16 +50,16 @@ print_usage (); endif - if (fs < 2 .* fc) + if (fs < 2 * fc) error ("amdemod: fs is too small must be at least 2 * fc") endif l = length (s); - t = 0: 1 ./ fs: (l .- 1) ./ fs; + t = 0: 1 / fs: (l - 1) / fs; - e = s .* cos (2 .* pi .* fc .* t); - [b a] = butter (5, fc .* 2 ./ fs); - m = filtfilt (b, a, e) .* 2; + e = s * cos (2 * pi * fc * t); + [b a] = butter (5, fc * 2 / fs); + m = filtfilt (b, a, e) * 2; endfunction @@ -80,16 +80,16 @@ %! Fm = 10; %! #Low-pass filter design -%! [num,den] = butter(10,1.2*Fc/Fs); +%! [num, den] = butter (10, 1.2 * Fc / Fs); %! #Signals -%! t = 0:1/Fs:T; -%! x = cos(2*pi*Fm*t); -%! y = ammod(x,Fc,Fs); -%! z = amdemod(y,Fc,Fs); +%! t = 0: 1 / Fs :T; +%! x = cos (2 * pi * Fm * t); +%! y = ammod (x, Fc, Fs); +%! z = amdemod (y, Fc, Fs); %! #Plot %! figure('Name','AM Modulation'); -%! subplot(3,1,1); plot(t,x); title('Modulating signal'); -%! subplot(3,1,2); plot(t,y); title('Modulated signal'); -%! subplot(3,1,3); plot(t,z); title('Demodulated signal'); \ No newline at end of file +%! subplot (3, 1, 1); plot (t, x); title('Modulating signal'); +%! subplot (3, 1, 2); plot (t, y); title('Modulated signal'); +%! subplot (3, 1, 3); plot (t, z); title('Demodulated signal'); diff -r 6b7d434d0e90 inst/ammod.m --- a/inst/ammod.m Wed Apr 27 17:54:24 2022 -0400 +++ b/inst/ammod.m Mon Sep 12 17:38:09 2022 +0000 @@ -48,13 +48,13 @@ print_usage (); endif - if (fs < 2 .* fc) + if (fs < 2 * fc) error ("ammod: fs is too small must be at least 2 * fc") endif l = length (x); - t = 0: 1 ./ fs: (l .- 1) ./ fs; - y = x .* cos (2 .* pi .* fc .* t); + t = 0: 1 / fs: (l - 1) / fs; + y = x * cos (2 * pi * fc * t); endfunction @@ -75,15 +75,15 @@ %! fs= 4000; %! %! ## time Duration -%! t = (0 : 1 ./ fs : 1); +%! t = (0 : 1 / fs : 1); %! %! ## sine Wave with time duration of 't' -%! x = sin (2 .* pi .* t); +%! x = sin (2 * pi * t); %! %! ## Amplitude Modulation %! y = ammod (x, fc, fs); %! -%! plot(y); -%! title('Amplitude Modulation'); -%! xlabel('Time(sec)'); -%! ylabel('Amplitude'); +%! plot (y); +%! title ('Amplitude Modulation'); +%! xlabel ('Time(sec)'); +%! ylabel ('Amplitude'); diff -r 6b7d434d0e90 inst/fmdemod.m --- a/inst/fmdemod.m Wed Apr 27 17:54:24 2022 -0400 +++ b/inst/fmdemod.m Mon Sep 12 17:38:09 2022 +0000 @@ -45,7 +45,7 @@ print_usage (); endif - if (fs < 2 .* fc) + if (fs < 2 * fc) error ("fmdemod: fs is too small must be at least 2 * fc") endif diff -r 6b7d434d0e90 inst/fmmod.m --- a/inst/fmmod.m Wed Apr 27 17:54:24 2022 -0400 +++ b/inst/fmmod.m Mon Sep 12 17:38:09 2022 +0000 @@ -53,10 +53,10 @@ endif l = length (m); - t = 0: 1 ./ fs: (l .- 1) ./ fs; - int_m = cumsum (m) ./ fs; + t = 0: 1 / fs: (l - 1) / fs; + int_m = cumsum (m) / fs; - s = cos (2 .* pi .* fc .* t .+ 2 .* pi .* freqdev .* int_m); + s = cos (2 * pi * fc * t + 2 * pi * freqdev * int_m); endfunction @@ -74,10 +74,10 @@ %! fc = 200; %! %! ## Time Duration -%! time = (0: 1 ./ fs:0.2)'; +%! time = (0: 1 / fs: 0.2)'; %! %! ## Create two sinusoidal signals with frequencies 30 Hz and 60 Hz -%! x = sin (2 .* pi .* 30 .* time) .+ 2 .* sin (2 .* pi .* 60 .* time); +%! x = sin (2 * pi * 30 * time) + 2 * sin (2 * pi * 60 * time); %! %! ## Frequency Deviation %! fDev = 50; @@ -89,4 +89,4 @@ %! plot (time, x, 'r', time, y, 'b--') %! xlabel ('Time (s)') %! ylabel ('Amplitude') -%! legend ('Original Signal','Modulated Signal') \ No newline at end of file +%! legend ('Original Signal','Modulated Signal')