Clear Filters
Clear Filters

Matlab 2023a: How can I set Window Length and NFFT in the Spectrum Analyser block in Simulink?

9 views (last 30 days)
The spectrum setting for the Spectrum Analyser in Simulink Matlab 2023a don't appear to allow direct adjustment of the Window Length and NFFT. They could easily be set in previous versions. Is there a way to change these settings?

Accepted Answer

Vandit
Vandit on 2 Feb 2024
Hi Donal,
I understand that you are facing difficulty in changing the 'Window Length' and 'NFFT' in the Spectrum Analyzer block in MATLAB R2023a.
From the below documentation, it looks like there is a change in the GUI of the Spectrum Analyzer block:
One workaround is to use the "set_param" and "get_param" functions, which are used to modify and retrieve block parameters in Simulink, respectively. Kindly refer to the following code snippet for modifying the 'Window Length' and 'NFFT' in the Spectrum Analyzer block:
% Get the current block path
>> gcb
ans =
'untitled/Spectrum Analyzer'
% Get the current Window Length
>> get_param(gcb,'WindowLength')
ans =
'1000'
% Set the Window Length to 1024 and verify the Window Length has been updated
>> set_param(gcb,'WindowLength','1024')
>> get_param(gcb,'WindowLength')
ans =
'1024'
% Get the current FFT Length (NFFT)
>> get_param(gcb,'FFTLength')
ans =
'256'
% Set the FFT Length to 1024 and verify the FFT Length has been updated
>> set_param(gcb,'FFTLength','1024')
>> get_param(gcb,'FFTLength')
ans =
'1024'
To know more about "set_param" and "get_param" functions, please refer to below documentations:
Hope this helps.
  1 Comment
Donal O'Toole
Donal O'Toole on 6 Feb 2024
Hi Vandit,
Thank you very much. The gcb, set_param and get_param commands go a long way to solving the issue. set_param(gcb,'FFTLength','1024') works perfectly on Matlab R2022b but get_param(gcb,'WindowLength') does not:
>> get_param(gcb,'WindowLength')
Scope block does not have a parameter named 'WindowLength'
The Window length parameter is clearly visible when I open the block in question so it's a bit surprising.
I've yet to try these commands on the Matlab R2023a version. I'll report back after I do.
Thanks again,
Donal

Sign in to comment.

More Answers (0)

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!