FIND requires variable sizing

21 views (last 30 days)
Idrees Idrees
Idrees Idrees on 28 Aug 2014
Commented: Idrees Idrees on 1 Sep 2014
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 Comments
Idrees Idrees
Idrees Idrees on 29 Aug 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 on 1 Sep 2014
it must be noted that i am using attribute function block of simevents

Sign in to comment.

Answers (1)

Andrew Reibold
Andrew Reibold on 29 Aug 2014
  2 Comments
Idrees Idrees
Idrees Idrees on 29 Aug 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 on 1 Sep 2014
it must be noted that i am using attribute function block of simevents

Sign in to comment.

Categories

Find more on Discrete-Event Simulation in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!