Finding Angular Frequency of an Oscillation

조회 수: 56 (최근 30일)
Macaulay Wright
Macaulay Wright 2020년 3월 31일
댓글: Star Strider 2020년 3월 31일
I have currently produced a code to plot a Van der Pol oscillator, I can calculate the period by physically looking at the graph, but I am unsure on how to do this using a MATLAB code to get a result digitally.
My main focus is to get a printed value for the angular frequency (w - omega), so my first thought was to calculate the period and then use the equation w = (2pi/T).
Please can I get some guidance on producing a small script to calculate angular frequency? (w = 1 with the current model)
I have attached the code for the oscillation below.
Thanks in advance.
% simulation parameters
DT = 0.01; % Time step
N = 10000; % number of discrete time points
% Equation parameter
mu = 0.1;
% declare array to store discrete time samples
x = zeros(1,N);
% set boundary conditions
x(1) = -0.01;
x(2) = 0.0;
% Simulate using recurrance relation
for i = 3:N
phi = mu*DT/2*(x(i-1)^2-1);
x(i) = x(i-1)*(2-DT^2)/(1+phi) - x(i-2)*(1-phi)/(1+phi);
end
% plot
plot((1:N)*DT,x,'r')
% Calculating angular frequency

채택된 답변

Star Strider
Star Strider 2020년 3월 31일
Likely the easiest way would be to find the times of the positive peaks, then calculate from there:
[pks,pktimes] = findpeaks(x, (1:N)*DT);
Period = mean(diff(pktimes))
The findpeaks function requires the Signal Processing Toolbox. A similar function is islocalmax, introduced in R2017b. (There are still other ways if you have neither of these functions.)
  댓글 수: 2
Macaulay Wright
Macaulay Wright 2020년 3월 31일
편집: Macaulay Wright 2020년 3월 31일
Thank you for the quick response, that piece of code works perfectly and was just what I was trying to acheive. I will now input the angular frequency equation using the new found period value.
Thank you again.
Star Strider
Star Strider 2020년 3월 31일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Design Condition Indicators Interactively에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by