How to programmatically set "Average reference power" and "reference phase offset (rad)" parameters for Simulink "Constellation Diagram" block in the Communications Toolbox for MATLAB R2024b?

6 views (last 30 days)

I am unable to programmatically access "Average reference power" and "reference phase offset (rad)" parameters for Simulink "Constellation Diagram" block in the Communications Toolbox for MATLAB R2024b. 
For a given model containing "Constellation Diagram" block, the "ReferenceConstellation" can be set using the following command. Setting it to 'QPSK' as an example.

>> set_param('<model_name>/Constellation Diagram', 'ReferenceConstellation', 'QPSK');
In the GUI, there is an option to set "Average reference power" and "Reference phase offset (rad)". However, when I try to use a similar approach to set it programmatically using the command, 

>> set_param('<model_name>/Constellation Diagram', 'AverageReferencePower', 10);
I get the following error:

ConstellationDiagram block does not have a parameter named 'AverageReferencePower'
Similar error is observed when trying to access "reference phase offset (rad)".

How do I set "Average reference power" and "reference phase offset (rad)" programmatically?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 19 Nov 2024 at 0:00
"Average reference power" and "reference phase offset (rad)" parameters cannot be programmatically modified as of MATLAB 2024b. 
However, the end result can be achieved by setting the existing “ReferenceConstellation” property of the “ScopeConfiguration” object to an appropriate numeric value (i.e., not as a preset such as 'QPSK' etc.).
To set the “ReferenceConstellation” and incorporate the desired values for "Average reference power" and "Reference phase offset (rad)" parameters, please follow the steps below:
 
Step 1: Obtain the “ScopeConfiguration” and store it in variable “cfg” using the following command:
>> cfg = get_param('<model_name>/Constellation Diagram', 'ScopeConfiguration')
You can now access the “ReferenceConstellation” property using the following command:
>> cfg.ReferenceConstellation
Step 2: The “ReferenceConstellation” property can be set to an appropriate numeric vector “val”, to obtain desired “Average reference power" and "Reference phase offset (rad)". This can be done using:
>> cfg.ReferenceConstellation = val
To construct the appropriate value (“val”) for “ReferenceConstellation” property, please refer to the example given for “Average Power Normalization for QAM” in the following documentation page: Quadrature amplitude modulation (QAM) 
Example: In case of QPSK, a basic constellation can be obtained as follows:
>> valTemp = qammod(0:3, 4);
The desired "Average reference power" can be obtained by appropriately scaling “valTemp” using “K”. The desired "Reference phase offset (rad)" can be obtained by multiplying with a complex exponent “exp(j* phi)”.
>> val = K * valTemp * exp (j* phi);
Then you can set the “ReferenceConstellation” property to “val”.
>> cfg.ReferenceConstellation = val
Here is a link to a documentation article that shows how to control scopes with programming scripts: Control Scope Blocks Programmatically

More Answers (0)

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!