필터 지우기
필터 지우기

Plot sin or cosine with Simulink scope

조회 수: 7 (최근 30일)
Javier
Javier 2015년 3월 24일
편집: Javier 2015년 3월 25일
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

채택된 답변

Javier
Javier 2015년 3월 25일
편집: Javier 2015년 3월 25일
Finally I solved it with the advices of Sebastian and making use of Mathworks blog.
Thus my solution was:
fo(carrier)= 2e6Hz
Be compliant with Nyquist: fs>=2*fo or Ts<=(To/2) where To=1/(2*fo)=2.5e-7s => Ts = 2.5e-7s
Model parameters
>> solver >> Max step size = Ts = 2.5e-7
>> solver >> Stop time = 0.05
>> Data Import/Export >> Output options : Refine Output >> Refine Factor = 100
Thus I got this signal

추가 답변 (1개)

Sebastian Castro
Sebastian Castro 2015년 3월 24일
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,
  1. Go to Simulation > Model Configuration Parameters and select the "Solver" pane on the left.
  2. 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).
  3. 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
Sebastian Castro
Sebastian Castro 2015년 3월 25일
편집: Sebastian Castro 2015년 3월 25일
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
Javier 2015년 3월 25일
Thanks for the advices Sebastian, thanks to then I have managed it but without using the buffers, just reducing the simulation time to 0.05s, a Ts=2..5e-6s(Max time step) and making use of the link I mention in my original post;that's to say, I have use the redefin option under "Data export" and I have set it at 100, then I got a good view of my signal.

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

카테고리

Help CenterFile Exchange에서 Scopes and Data Logging에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by