sine with increasing frequency

10 次查看(过去 30 天)
Max E.
Max E. 2015-9-5
in my opinion, the following code should produce a sine-wave that has a frequency of 2Hz at t=20. but when i count the periods between t=19 and t=20, i count more than 3 periods. what am i doing wrong?
clear all, close all, clc;
t=linspace(0,20,10000);
y=sin(2*pi*(1+(5/100)*t).*t);
plot(t,y);
hold on;
  2 个评论
Image Analyst
Image Analyst 2015-9-5
If you have the signal processing toolbox, you might also be interested in the chirp() function.
Max E.
Max E. 2015-9-5
i'm actually using this function in simulink, which genereally includes a chirp block. The problem is, that i can't make the chirpblock start at a specific time, but it always starts at the beginning of the simulation. But what is the processing toolbox and where can i get it?

请先登录,再进行评论。

回答(1 个)

Star Strider
Star Strider 2015-9-5
You’re multiplying by t first, then element-wise by .*t. I also don’t understand what the 1 is for.
See if this does what you want:
t=linspace(0,20,10000);
y=sin(2*pi/20.*t.^2);
  3 个评论
Max E.
Max E. 2015-9-5
the 1 is the "initial-condition" for the frequency. if i use your function i get a sinus, that's starting with a frequency of 0Hz and then going up to a frequency of 2Hz. But since i got a solution to my problem on another board meanwhile, here's the answer: if you have function sin(x(t)) you can calculate the frequency as w=2*pi*f=dx(t)/dt. so what i had to do was integrating my frequency function over t. the result is this: y=sin(2*pi*t.*(1+1/40*t))
the orange one is your function, the blue one is mine. as you can see, mine starts at a frequency of 1Hz and goes up to 2Hz at the end. And just for your information: the first time you don't have to multiplicate element-wise since you don't have a vector yet, but a scalar. only the power function has to be an element-wise multiplication
Star Strider
Star Strider 2015-9-5
I still don’t understand what you want, but so long as you got your answer, we’ll consider this resolved.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by