This is my code for generating a TTL wave with frequency 30 Hz and modulate it with FSK and carrier frequency 400
f=30;
T = 1/f;
t = linspace(0, T*10, 1000);
y = (1/2)*square(t/T*2*pi)+(1/2);
plot(t, y);
hold on;
fc=400;
df=20;
y_m = cos(2.*pi.*(fc+(2.*y).*df).*t);
plot(t,y_m);
hold off;
First of all, I have phase discontinuity when TTL changes from 0 to 1 or viser versa, and the second problem is that the domain of modulated signal is not the same every where and it changes...
How Can I solve these problems?