setting the size of output port for Level-2 Matlab functions

1 visualización (últimos 30 días)
defunct C7=5F>20
defunct C7=5F>20 el 11 de Jun. de 2012
Hi, all!
I have the following questions: i am writing level 2 function, that takes an image of unknown size as an input and resizes it (i know that it exists in computer vision toolbox, but i dont have licence).
So i want to set dimenstions of the output port on setup (not to use variable-size signals). If the output image would be the same size as input image, i just dont specify dimenstions in the setup method, but the default behaviour assumes, that the output image size is equal to the input image size. Is there any way to change this behaviour except using variable-size signals?
It should be possible to specify output image size before simulation, since input image size is known before simulation.

Respuestas (1)

Kaustubha Govind
Kaustubha Govind el 11 de Jun. de 2012
I'm not sure if I understand your question correctly. Did you mean that you'd like to have a variable-sized output, or did you want to keep it fixed-sized (like the input)? If it is the latter, does using something like this in setup() help:
block.OutputPort(1).Dimensions = block.InputPort(1).Dimensions;
  2 comentarios
defunct C7=5F>20
defunct C7=5F>20 el 12 de Jun. de 2012
I dont want to have variable -sized output, since the dimensions of signal during one simulation are not changing. However, they can change between simulation (since i am doing image resizing in the block, dimensions of the output depend on scaling parameter and the size of input image).
The problem is, that in setup method block.InputPort(1).Dimensions are not know. They are known during 'compilation'(?) time. By default, block.OutputPort(1).Dimensions are expected to be equal block.inputPort(1).Dimensions (e.g. it is expected when no Dimensions are specified). I solved the problem by setting the dimensions in the callback SetInputPortDimensions:
function SetInputPortDimensions(block, idx, di)
scale = block.DialogPrm(2).Data;
block.OutputPort(1).Dimensions = ceil(block.InputPort(1).Dimensions*scale);
Is there any documentation on the order, in which callbacks are called?
Kaustubha Govind
Kaustubha Govind el 13 de Jun. de 2012
Ah! I see what you mean. Thanks for posting your solution,
There is a "Process View" flowchart that lists C-MEX S-function methods: http://www.mathworks.com/help/releases/R2011b/toolbox/simulink/sfg/f8-37326.html#f8-83424
You can refer to this list to see how the MATLAB S-function methods correspond to C-MEX S-function methods: http://www.mathworks.com/help/releases/R2011b/toolbox/simulink/sfg/f7-67622.html#f7-68222

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by