|
Hi Simon, why not use modulate() with the pm or fm option, depending on what you want?
wayne
"Simon Luk" <simon.luk@student.uts.edu.au.REMOVETHIS> wrote in message <h07llp$rvk$1@fred.mathworks.com>...
> Hi All,
>
> I am trying to perform frequency modulation on a signal, but unfortunately I do not know what I'm doing wrong. Below is my code.
>
> Red is the message signal
> Blue is the modulated signal
>
>
> clear all
> close all
> ts=1/300000; % sampling interval
> fc=50000; % carrier frequency
> fs=1/ts; % sampling frequency
> fm = 2000;
> t=[0:ts:0.002]; % time vector
> kf=2000; % deviation constant
> m=cos(2*pi*fm*t); % the message signal
>
> int_m(1)=0;
> for i=1:length(t)-1 % integral of m
> int_m(i+1)=int_m(i)+m(i);
> end
>
> mod_signal(1) = cos(2*pi*fc*ts+2*pi*kf*ts*int_m(1));
> for i=1:length(t)-1
> mod_signal(i+1) = cos(2*pi*fc*i*ts+2*pi*kf*ts*int_m(i));
> end
>
>
> plot(t,m(1:length(t)))
> hold on;
> plot(t,mod_signal(1:length(t)), 'r')
> xlabel('Time')
>
>
> Someone able to tell me what is wrong? My modulated signal doesn't seem to be correct I dont think.
>
> Thanks.
>
> Regards,
> Simon
|