Hi Noah,
When you are trying to set the denominator parameter it failed because the format of the string passed to “set_param” is not properly represented.
The function “num2str” converts denominator vector into a string generates a space-separated list of numbers which is not a valid MATLAB expression for a vector. Simulink expects the vector to be formatted in MATLAB syntax, enclosed in square brackets with elements separated by spaces or commas
To rectify this use “mat2str” for converting the denominator to a string. This converts a vector into a valid MATLAB expression format including the necessary square brackets.
Here I am providing the example code snippet
% Convert the numerator and denominator to a string representation of a MATLAB vector
numStr = mat2str(num); % Converts to a string with square brackets, e.g., "[1, 5]"
denonStr = mat2str(denon); % Converts to a string with square brackets, e.g., "[1, 2, 3]"
% Set the parameters for the Transfer Function block
set_param('instsys/Generic Filter', 'Numerator', numStr);
set_param('instsys/Generic Filter', 'Denominator', denonStr);
You may refer to this documentation link for more information on “mat2str”
