As in MATLAB®, you index substructures and fields structures in MATLAB Function blocks by using dot notation. However, for code generation from MATLAB, you must reference field values individually (see Structure Definition for Code Generation).
function [outbus, outbus1] = fcn(inbus) %#codegen substruct.a1 = inbus.ele3.a1; substruct.a2 = int8([1 2;3 4]); mystruct = struct('ele1',20.5,'ele2',single(100), 'ele3',substruct); outbus = mystruct; outbus.ele3.a2 = 2*(substruct.a2); outbus1 = inbus.ele3;
The following table shows how the code generation software resolves symbols in dot notation for indexing elements of the structures in this example:
|Dot Notation||Symbol Resolution|
|Value of field |
|Value in row 1, column 1 of field |