sine with increasing frequency

조회 수: 12 (최근 30일)
Max E.
Max E. 2015년 9월 5일
댓글: Star Strider 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