How to find the exact period for given equation?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have an periodic equation, but i can't find the exact period of this equation with analytic method.
Can i derive the exact period of this equation using matlab?? (surely, solving equation with very small time interval, i can derive approximated time, but this is not enough.
Respuestas (1)
Shreshth
el 6 de Dic. de 2023
Hello JaeSung,
Yes, you can find the period of a periodic function numerically using MATLAB if an analytic solution is difficult or impossible to obtain. While a numerical solution may not give you the exact period, it can provide a highly accurate approximation.
Here is a general approach you could use in MATLAB to find the period of a function:
- Define the function in MATLAB.
- Use a numerical solver to find two consecutive points where the function crosses a specific value (often zero) with the same slope direction. These points are one period apart.
- Calculate the difference in the x-values (time) of these points to estimate the period.
Here's an example MATLAB script that demonstrates this process for a hypothetical function f(t):
% Define the function as an anonymous function
f = @(t) ...; % Replace with your actual function
% Define the time span to search for zero crossings
tspan = [0, 100]; % This is an example; adjust as needed for your function
% Find zero crossings of the function
% You may use a numerical solver or the 'findchangepts' function for this
options = optimset('TolX',1e-6);
t1 = fzero(f, tspan(1), options);
t2 = fzero(f, t1 + eps, options);
% The period is the difference between the two zero crossings
period = t2 - t1;
% Display the period
fprintf('The estimated period of the function is %f\n', period);
Keep in mind that this script assumes the function f(t) is continuous and differentiable, and that it crosses zero at least once per period. If the function crosses a different value than zero, you would need to adjust the function accordingly (e.g., by defining a new function g(t) = f(t) - c, where c is the value it crosses periodically).
Also, the initial guesses for the fzero function are crucial. You should have a rough idea of the period to set a proper range for the initial guesses. If the function has multiple zero crossings within a period, you'll need to ensure that t1 and t2 are indeed one period apart, not just any two consecutive zero crossings.
Thank You,
Shubham Shreshth
1 comentario
Walter Roberson
el 6 de Dic. de 2023
Note that this approach will not work if the function has multiple crossings per period. Consider for example multiplication of two sine waves: you need to use Lowest Common Multiple / Greatest Common Divisor calculations to calculate the period of the modulated signal.
Also this approach does not work for cases that do not have true periods. An example of this is bessel functions: they approach period of 2 pi but they do not reach it.
Ver también
Categorías
Más información sobre Quadratic Programming and Cone Programming en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!