# How to generate a signal which frequency are obtained?

I want to generate a signal which frequency are obtained. For example,I want the frequency domain similiar to this one: So I use the following code:

fs =44100;
t = 0:1/fs:4;
f = 800 + 500*sin(2*pi*t);
x = sin(2*pi*f);
plot(t,x)


But using Adobe Audition to visualize its spectrogram.

It looks different from my hope. So how can I generate a signal if already have freqency?

• your code is plain wrong; why is there a sine in your f formula? – Marcus Müller Aug 16 '16 at 14:20

$f(t)=\int_0^t800+500\sin{2\pi t}=\phi_0 + 800t -\frac{500}{2\pi} \cos(2\pi t)$
If you set the zero phase $\phi_0=0$, then you would obtain the signal you are looking for. Apart from that, take into account that if you just want that signal in the positive part of the spectrum of your double sided spectrum, then you should do $e^{if(t)}$, because if you just take the sine of $f(t)$ then the signal would be replicated in your negative side of the spectrum.
• Thank you!Reading your answer,I know how to do it.fs =44100; t = 0:1/fs:4; f= 800 + 300*sin(2*pi*t); x = sin(cumsum(f)/fs*2*pi); spectrogram(x,512,256,512,fs,'yaxis'); – partida Aug 17 '16 at 3:26