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

6 次查看(过去 30 天)
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?

采纳的回答

Vandit
Vandit 2024-2-2
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 个评论
Donal O'Toole
Donal O'Toole 2024-2-6
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by