Azzera filtri
Azzera filtri

How do you access the datatype of Bus Element Ports in MATLAB

4 visualizzazioni (ultimi 30 giorni)
I have a model that outputs a Bus of type 'TestBus'. The Bus is comprised of three Doubles, which I define and output using 'Bus Element Outports'.
I would like to access the output datatype of my entire model (which is a 'TestBus'). However, when I access the datatype of the Bus Element Outports, I receive 'Double' instead of 'TestBus'. 
For instance, the following code returns 'Double' on my compiled model:
get(<Bus Element Handle>,'CompiledPortDataTypes').Inport{1}; % Returns Double, should return TestBus
How can I access the Bus output datatype of my Bus Element Ports?

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 26 Lug 2024 alle 0:00
In order to get the Bus datatype of the Bus Element Outports, you must use the complete path of the port rather than the complete path of the block
get_param(<Path to Port>,'OutDataTypeStr') % returns 'Bus: TestBus'
In order to get the path to your port, you can double click on your Bus Element Block to open its properties -- at the top, you will see a 'Port name' text box. Alternatively, you can programmatically access the 'Port name': 
pathToPort = [get(<Block Handle>,'Path'), '/', get(<Block Handle>,'PortName')]
dataType = get_param(pathToPort, 'OutDataTypeStr');
If you are looking to get the output datatype of normal Outports, you must follow your original method, using the 'CompiledPortDataTypes' property. 

Più risposte (0)

Prodotti


Release

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by