FIND requires variable sizing

i am facing a problem of "Find requires variable sizing" whenever i compile my matlab function block of simevents. the scenario is simple that is i have to fimd the indexes from an array using find function: min_loc = find(pat_w_time(:,k)==min(pat_w_time(:,k)));
i have tried to google it a lot and also tried to search mathworks but all in vain moreover i have also tried code.varsize and emel.varsize but agian i am getting error. help appreciated

3 comentarios

Kaustubha Govind
Kaustubha Govind el 29 de Ag. de 2014
Could you post a simplified version of your function with use of coder.varsize? Is min_loc an output of the block, or just a local variable?
Idrees Idrees
Idrees Idrees el 29 de Ag. de 2014
thanks for prompt reply the simplified version of code that i tried are
version 1
coder.varsize('min_loc', [1, inf])
%%%%code to calculate pat_w_time %%%
min_loc = find(pat_w_time(:,k)==min(pat_w_time(:,k)));
here inf because in case upper bound is not known
version 2
coder.varsize('min_loc', [1, 20])
%%code to calculate pat_w_time %%%
min_loc = find(pat_w_time(:,k)==min(pat_w_time(:,k)));
here 20 because i know that pat_w_time has maximum size of 1*20
but i get error
"The coder.varsize() built-in function can only be used when support for dynamic matrices is turned on."
although its solution seems to be available at http://www.mathworks.com/help/releases/R2011b/toolbox/simulink/ug/br9_55w.html but i cannot access it
min_loc is neither output nor input to my matlab function block it is just created inside the block to get the location of minimum values from an array of pat_w_time so that further inferences can be made upon.
Idrees Idrees
Idrees Idrees el 1 de Sept. de 2014
it must be noted that i am using attribute function block of simevents

Iniciar sesión para comentar.

Respuestas (1)

Andrew Reibold
Andrew Reibold el 29 de Ag. de 2014

0 votos

2 comentarios

Idrees Idrees
Idrees Idrees el 29 de Ag. de 2014
firstly thanks for prompt reply Yes the link provides nearly two solution first one is " I used a fixed matrix and it finally fixed the issue." i tried to define a fixed size array of various lengths like 1*1, to 20*1 as my pat_w_time has maximum 20 values for which i get "Size mismatch" error because i don't exactly know how much locations find will return... while the second one is given at "See this newsgroup post for one explanation." "http://newsgroups.derkeiler.com/Archive/Comp/comp.soft-sys.matlab/2009-03/msg01457.html" in which it is clearly stated that one cannot get good results as find can give by the second method for which i am afraid off.
but my problem although looks same like the one indicated by the link given but yet unable to solve it according to the said methods
Idrees Idrees
Idrees Idrees el 1 de Sept. de 2014
it must be noted that i am using attribute function block of simevents

Iniciar sesión para comentar.

Categorías

Más información sobre Discrete-Event Simulation en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 28 de Ag. de 2014

Comentada:

el 1 de Sept. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by