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

21 vues (au cours des 30 derniers jours)
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?

Réponse acceptée

Vandit
Vandit le 2 Fév 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 commentaire
Donal O'Toole
Donal O'Toole le 6 Fév 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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Model, Block, and Port Callbacks dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by