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

조회 수: 6 (최근 30일)
Andy
Andy 2015년 8월 12일
답변: Chaitali Gondhalekar 2015년 8월 14일
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'."

답변 (1개)

Chaitali Gondhalekar
Chaitali Gondhalekar 2015년 8월 14일
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!

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by