How to access a signal from a bus structure inside matlab function
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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'."
0 Kommentare
Antworten (1)
Chaitali Gondhalekar
am 14 Aug. 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!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Structures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!