sine with increasing frequency

12 views (last 30 days)
Max E.
Max E. on 5 Sep 2015
Commented: Star Strider on 5 Sep 2015
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 Comments
Image Analyst
Image Analyst on 5 Sep 2015
If you have the signal processing toolbox, you might also be interested in the chirp() function.
Max E.
Max E. on 5 Sep 2015
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?

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 5 Sep 2015
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 Comments
Max E.
Max E. on 5 Sep 2015
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 on 5 Sep 2015
I still don’t understand what you want, but so long as you got your answer, we’ll consider this resolved.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!