Using matrix inputs with level 2 S-functions
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm attempting to pass a matrix into a Matlab level 2 S-function block in simulink. My goal is to allow an inherited input port size, so I have in my setup block:
block.SetPreCompInpPortInfoToDynamic;
for i=1:3
block.InputPort(i).DatatypeID = 0; % double
block.InputPort(i).Complexity = 'Real';
block.InputPort(i).SamplingMode = 'Sample';
block.InputPort(i).SampleTime = [-1,0.0];
block.InputPort(i).Dimensions=-1;
block.InputPort(i).DirectFeedthrough = true;
end
block.RegBlockMethod('SetInputPortDimensions',@SetInpPortDims);
which simply does
function SetInpPortDims(block, idx, di)
block.InputPort(idx).Dimensions = di;
The toy model I build to illustrate the problem simply takes a constant (1), pads it to be a 100 element vector, and then uses a vector concatenate block to create a 100x3 matrix. When I pass this into my S-function block I get the error:
Error in port widths or dimensions. Output port 1 of 'untitled/Vector Concatenate' is a [100x3] matrix. Error in port widths or dimensions. Invalid dimension has been specified for input port 1 of 'untitled/Convert ECEF to NED'.
If I set the input size of the S function to [100 3] on the correct input ports this works fine. The problem seems to be that the function SetInpPortDims (registered to do 'SetInputPortDimensions') is only called once for my third input (which is not a matrix). It is never called for the two matrix inputs.
The documentation says that when Simulink cannot fully determine the size of the input port, this function isn't called. How can I help if fully define the input signal size? I've tried adding a signal specification block with fixed size of 100x3 which only changes my error to
Error in port widths or dimensions. Output port 1 of 'untitled/Signal Specification' is a [100x3] matrix. Error in port widths or dimensions. Invalid dimension has been specified for input port 1 of 'untitled/Convert ECEF to NED'.
Thanks for your support
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Block and Blockset Authoring en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!