How to access a signal from a bus structure inside matlab function

3 visualizaciones (últimos 30 días)
Andy
Andy el 12 de Ag. de 2015
Respondida: Chaitali Gondhalekar el 14 de Ag. de 2015
Is it possible to select a signal from a bus structure inside a MATLAB function and then scale it and then assign it to an output?
e.g. some thing like the following:
function [output] = myfunc(input, signalSelection, scaling)
% #codegen
output = input(signalSelection)*scaling;
end
where input is a defined bus structure, signalSelection is a uint32 and scaling is a single?
The error I keep getting is "Function 'mtimes' is not defined for values of class 'struct'."

Respuestas (1)

Chaitali Gondhalekar
Chaitali Gondhalekar el 14 de Ag. de 2015
I understand that you want to access a single signal from a Bus structure in the MATLAB workspace.
Assuming that you are using "Simulink.Bus.createMATLABStruct" to create the Bus structure "input" mentioned in your code snippet, you can access its fields with a dot operator and scale it using the "scaling" parameter. For example, if your Bus structure has a signal "pulseSignal", you can access it as
>> output = input.pulseSignal * scaling
Hope this helps!

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by