Plot sin or cosine with Simulink scope
Mostrar comentarios más antiguos
Hello all,
I would like to do some simulate some home-made modulation with Simulink, but first things first; so I was trying to plot the output ( a sin wave) from a signal generator into a Simulink scope, however I am coming across a issue when depicting the output into the scope, since I don´t get my sin signal but I got some crappy signal instead as it can be seen below, and looking at its PSD I think I am loosing samples or something with the simulation step.


I have found some aid in this Matlab blog, however, I cannot get the plot that I would like to, my signal input is a sin with f=2.1e6.
Is there something I can do to get my sin signal in the scope?
Thanks in advance,
Regards!
EDIT: I am using matlab2014a
Respuesta aceptada
Más respuestas (1)
Sebastian Castro
el 24 de Mzo. de 2015
1 voto
Javier,
By default, if no other blocks drive it, Simulink will choose a sample time of 1/50 the total time -- so, in your case, 2000/50 = 40 seconds. This is definitely too large for a 2.1 MHz sine wave.
To fix this,
- Go to Simulation > Model Configuration Parameters and select the "Solver" pane on the left.
- Once you're there, you can change the "Max time step" parameter to something acceptable -- i.e., anything below 1/(2*fs), and probably an integer divisor of (1/fs).
- If you don't think you need the default variable-step solver in Simulink, you can change to a fixed-step solver with a sample time similar to what I described above.
Does this solve your problem?
- Sebastian
3 comentarios
Sebastian Castro
el 25 de Mzo. de 2015
Editada: Sebastian Castro
el 25 de Mzo. de 2015
You interpreted my point correctly. I used "fs" to mean the sampling frequency -- so yes, you choose a sample time such that aliasing is prevented.
Also, I think it's expected for the simulation to take forever. If you're running a 2000-second simulation with a sample time of 2.5e-7, there are a lot of data points to process.
One thing you can do is change from sample-based (one sample at a time) processing to frame-based processing (using buffers). Look at the following link:
- Sebastian
Javier
el 25 de Mzo. de 2015
Categorías
Más información sobre Scopes and Data Logging en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
