- Sine Wave in continuous mode generate samples at each simulation step. Spectrum Analyzer expects a uniformly sampled, discrete-time signal, where the sample rate is determined by the solver step size. For step size 1e-04, Sample rate = 1/1e-4 = 10,000 Hz. For a 50 Hz sine wave, this is more than enough according to Nyquist criterion, so the spectrum is accurate. For step size 1e-06, Sample rate = 1/1e-6 = 1,000,000 Hz. Now, the Sine Wave block is generating way more samples than needed. The spectrum appears distorted because the signal is oversampled.
- For discrete systems, the solver step size should match the fastest sample time in your model. For more details you can go through the following documentation https://www.mathworks.com/help/simulink/ug/compare-solvers.html#f7-14323
- To simulate propagation delay, use the Delay block (for discrete signals) or the Transport Delay block (for continuous signals). For discrete signals, set the delay as an integer of number of samples, which should match your signal’s sample time. For continuous signals, set the delay in seconds, but accuracy improves if the solver step is much smaller than the delay.
I'm running signal processing simulations in Simulink. What's the proper way to set the solver step size?(I've attached my .slx file, tks!)
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
1. Solver Configuration for AM Modulation/Demodulation
I'm building an AM modulation/demodulation model in Simulink using the DSP System Toolbox. My signal source is a Sine Wave (continuous mode) block.
- Solver Type: Should I use fixed-step or variable-step solver for this scenario?
- Step Size Issue: When I set a fixed step size of 1e-04, the Spectrum Analyzer block correctly shows the power spectrum of a 50Hz sine wave. However, if I reduce the step to 1e-06, the spectrum becomes distorted. Why does a smaller step size lead to incorrect results? (Intuitively, shouldn't smaller steps improve accuracy?)
2. Discrete Mode vs. Solver Step
Even though I currently use Sine Wave in continuous mode, I'd like to understand how to configure it in discrete mode:
- In discrete mode, the Sine Wave block requires a sample time parameter. How does this sample time relate to the solver's step size?
- What’s the rule for setting the solver step when the signal source is discrete?
3. Modeling Signal Propagation Delay
In my current model, the receiver starts demodulating the signal immediately after the transmitter generates it (no propagation delay). This is unrealistic. How can I simulate a time delay between transmission and reception?
- Is there a specific block (e.g., Delay or Variable Transport Delay) recommended for this purpose?
- Should the delay time be aligned with the solver step size or the signal's sample time?
Additional Context:
- MATLAB Version: R2024a
- Toolboxes: Simulink, DSP System Toolbox
Below is my model and the blocks used, with relevant parameters annotated in the diagram.

When I set step = 1e-04:

when I set step = 1e-06:

0 Commenti
Risposte (2)
Samhitha
il 22 Apr 2025
For signal processing applications especially when using Spectrum Analyzer you should fixed-step solver. Because fixed-step solvers give a consistent sample time, which is important for correct frequency analysis.
For more details look into this following documentation
Hope this helps!
2 Commenti
Paul
il 26 Apr 2025
Hi ColdRabbit,
As long as the Sample Time parameter of the ZOH block is set to the sampling period for which you want to compute the spectrum, it won't matter if you use a variable or fixed-step solver. If the ZOH block Sample Time is set to -1, then one should use a fixed-step solver and the ZOH output will be sampled at the solver steps. Sample Time set to -1 with a variable step solver would probably be undesriable. Probably best to speficy the ZOH Sample Time explicitly instead of inherited.
The Spectrum Analyzer block will operate at the sample time of the input signal unless it's set explicitly under the Scope tab. Based on the pictures, it looks like you're using the default parameters for the Spectrum Analyzer block. Note that in both cases (Ts = 1e-4, Ts = 1e-6), the analyzer is using 1024 samples per update. With Ts = 1e-4, with 1024 samples we have
Nperiods = 1024*1e-4*[50 1000]
of data per update. But for T = 1e-6, we have
Nperiods = 1024*1e-6*[50 1000]
which probably isn't enough information to compute the spectrum.
Try exploring the parameters under the Estimation -> Freqeuency Resolution to get more samples per update.
3 Commenti
Paul
il 26 Apr 2025
Modificato: Paul
il 26 Apr 2025
The parameters under the Frequency Resolution tab have interdpendencies on each other (and on parameters under other tabs). According to the doc page, whether or not the Window Length parameter is enabled depends on the settings of the Estimation Method and the Resolution Method. I only scanned the doc age and played around with the model tyring different parameters. I suggest reading the relevant portions of the doc page in detail to achieve whatever is needed.
Vedere anche
Categorie
Scopri di più su Spectral Analysis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!