Unknown dimension of inport in simulink block (M-file)

Discussion in 'MATLAB' started by Sebastian Pliefke, Nov 11, 2009.

  1. Hi

    In the last minutes I tried to create a simulink block as M-File with an inport where I doesn't know the dimension. The port could be a single value (1x1) or a vector (1xn).

    block.InputPort(10).Dimensions = [1 -1];
    block.InputPort(10).DatatypeID = 0; % double
    block.InputPort(10).Complexity = 'Real';
    block.InputPort(10).SamplingMode = 'sample';

    I tried several thinks to deal with unknown dimensions for inports but everything ends into a "compiler error" and avoid the start of the model. Does anyone know how to declare such a kind of inport.

    Thx 4 help
    Sebastian Pliefke, Nov 11, 2009
    1. Advertisements

  2. Sebastian Pliefke

    Rakesh Bose Guest

    Hi Sebi,

    I assume that you are using block based sample time...In that case its hard to believe that one of the abose line of code should result in "compiler error". The first thing i would recommend is to establish the cause of error. If its "block.InputPort(10).Dimensions = [1 -1];" causing error, try setting the dimensions using "SetInputPortDimensions" method. Does it work ok if you set the dimension to [1 1] and have a 1x1 input?

    Rakesh Bose, Nov 11, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.