Why does Simulink generate a sine wave as a triangle wave?

21 vues (au cours des 30 derniers jours)
monmatlab
monmatlab le 24 Oct 2015
Commenté : azeddine le 26 Juin 2023
Hey community, i am new to Simulink. I wanted to generate a sine wave : sin(15*2*pi*t). But I always get a triangle wave even the amplitude is incorrect.
(see pictures)
Is there something I'm doing wrong?
thank you!
  2 commentaires
Stephen Ofori
Stephen Ofori le 17 Jan 2019
I'm also having the same problem here, it works fine when I take the pi
But generate a triangular wave when the pi is there
Yazdan Tanveer
Yazdan Tanveer le 23 Déc 2019
You have to take care of “simulation stop time”. Simulink sets the step size by default according to simulation stop time. If you want to change it manually regardless of simulation stop time, you have to adjust the ‘sample time’ in the properties of the sine block.

Connectez-vous pour commenter.

Réponse acceptée

Sebastian Castro
Sebastian Castro le 24 Oct 2015
Modifié(e) : Sebastian Castro le 24 Oct 2015
This is definitely a sampling issue. You need to run the model at a faster rate to adequately capture the generated signal.
What's the time step size in your model? Go to the model configuration parameters and check the sample time options in the Solver pane.
Based on the Nyquist criterion, you need to sample the signal AT LEAST at twice its frequency. In your case, that is 30 Hz, or 1/30 sec sample time. To be safe, you should use an even smaller sample time.
EDIT: If you see your model has an "auto" step size, this depends on your version. If you're using one of the newest versions, Simulink can actually try use your block's frequency to decide a better sample time. However, the traditional value for a while before that has been (1/50) of the total simulation time, which is probably too large given your parameters.
- Sebastian
  2 commentaires
Hussain Ali
Hussain Ali le 15 Sep 2018
it means that simulation time should be less then half of time period.
azeddine
azeddine le 26 Juin 2023
hi sebastien,
i need to generat a sine wave up to 20KHz, but the sample time of my reel time simulink model must be 0.01S. can u propos any solution ?
best regards.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by