Effacer les filtres
Effacer les filtres

Problem Implementing a sine wave with increasing frequency

3 vues (au cours des 30 derniers jours)
chang low
chang low le 19 Août 2015
Modifié(e) : Alberto llosa le 1 Déc 2022
Hi,
I would implement a sine wave with frequency that increases from 0 to 50 and stay constant afterwards. The model i used is on the top left and frequency input on bottom left. However, the output results( firgure right) i obtained contains a frequency higher than 50Hz but I don't know why. What went wrong?
matlab function code
function y = sin(f,t,ps)
%generates a sine wave of frequency f and phase shift of ps (in radians)
y = sin(2*pi*f*t+ps);
Here's my model
  3 commentaires
Purushottama Rao
Purushottama Rao le 19 Août 2015
can you attach the model?
Alberto llosa
Alberto llosa le 1 Déc 2022
Modifié(e) : Alberto llosa le 1 Déc 2022
I´m having the same issue and will not able to solution this up to now. I have intended a number of solutions as working with the implemented sine wave simulink block and also using an S shape curve for varying the frequency without abrupt changes and the behavior is the same. I believe it is a problem on the code used to generate the sin wave. At this moment this problem is challinging us since I´m not being able to attend customer needs on the simulation we are working with.

Connectez-vous pour commenter.

Réponse acceptée

Purushottama Rao
Purushottama Rao le 19 Août 2015
Modifié(e) : Purushottama Rao le 19 Août 2015
The problem with your model is dynamic freqency change faster than the generation of sine wave itself. Say for example, at a given instant the frequency input to the function call is 20HZ. Depending on the clock value at that instant, MATLAB refers to 20HZ sine wave and takes a sample out of it. For the very next sample, you are changing the frequency to 21HZ (say), and therefore matlab has to look for the 21HZ sine wave and depending on the clock, it gives the output. Therefore the output frequency can not be defined during the ramp period in your model.
In order to define the frequency effectively, you may have to reduce the sampling rate of your frequency alone such that matlab completes one cycle atleast for the frequency input. But in your case this seems to be not possible because for matlab to complete 1HZ sine wave, 1sec is requied.After 1sec, your ramp is already at 50HZ. Therefore you dont see the way you are looking for

Plus de réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 19 Août 2015
If the maximum frequency is
f=50,
set the max step size (in model configuration parameters) to
0.1/f
  1 commentaire
chang low
chang low le 19 Août 2015
The output just became more distorted. Might the problem be due to my implementation method instead

Connectez-vous pour commenter.

Catégories

En savoir plus sur Event Functions dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by