Problem with matlab function block.

3 visualizaciones (últimos 30 días)
dimitris
dimitris el 5 de Feb. de 2012
Comentada: Yanbo el 17 de Oct. de 2013
I use a matlab function block in my simulink model and when i read a variable(for example N) from a file i get an error, but if i write N=2 it works fine. The problem is that i have to read this variable from a file. The error is : "Computed maximum size is not bounded. Static memory allocation requires all sizes to be bounded. The computed size is [:? x 1] Function 'MATLAB Function' : B=zeros(N,1,'double')". Any ideas are welcome. Thank you in advance.

Respuesta aceptada

Kaustubha Govind
Kaustubha Govind el 6 de Feb. de 2012
The MATLAB Function block does not allow dynamic sizing of variables. The best you can do is figure out a maximum size for your variable, and then declare it as follows:
coder.varsize('B', [128 1]);
B = zeros(N, 1);
  1 comentario
Yanbo
Yanbo el 17 de Oct. de 2013
Hi Kaustubha,
Can coder.varsize be replaced by eml.varsize ? I am not quite sure about the difference between the two, and what toolbox shall I download to enable coder, as currently my matlab doesn't support coder.
Cheers,
Yanbo

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 5 de Feb. de 2012
You will need to allocate the memory first with a fixed maximum size, and then if you find that N is smaller than that size you can delete the extra storage from the array.

Categorías

Más información sobre Simulink Functions 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!

Translated by