Why do I receive an "Error in port widths or dimensions" error when I set default input dimensions in Simulink when the input ports are initialized dynamically?
1 view (last 30 days)
Show older comments
MathWorks Support Team
on 5 Aug 2010
Edited: MathWorks Support Team
on 5 Feb 2016
I have created a Level-2 MATLAB file S-function. I have two inputs. One of the inputs is a vector and the other input is a matrix. I use the following code to initialize the dimensions of my inputs:
block.SetPreCompInpPortInfoToDynamic;
By doing this, I receive the following error: ERROR: Error in port widths or dimensions.
Accepted Answer
MathWorks Support Team
on 5 Feb 2016
Edited: MathWorks Support Team
on 5 Feb 2016
In order to use several ports which inherit their dimensions from the input ports, you can use the SetInpPortDims method as follows
block.RegBlockMethod('SetInputPortDimensions', @SetInpPortDims);
function SetInpPortDims(Block, port, dims)
Block.InputPort(port).Dimensions = dims;
The attached example illustrates this.
0 Comments
More Answers (0)
See Also
Categories
Find more on Block and Blockset Authoring in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!