Coder, randsample: Variable 'edges' is not fully defined on some execution paths.
4 views (last 30 days)
I'm trying to compile a Matlab code with the coder that calls randsample(n,k,true,w) for integers n and k and a weight-vector w. I get the error message, "Variable 'edges' is not fully defined on some execution paths." which seems to be a problem within the randsample function. Any ideas what to do without touching randsample.m itself? Thanks
Mike Hosea on 31 Jul 2018
Edited: Mike Hosea on 31 Jul 2018
This is a bug in the code generation version of RANDSAMPLE. The compiler is complaining about a situation that it really doesn't need to complain about, as the edges variable is never referenced unless it is first defined as far as I can tell. It's just challenging to infer that from a static analysis.
I'll create an internal bug report for this to get it fixed. It's really just a matter of providing an initialization for edges even when w is empty (e.g. adding
edges = zeros('like',w);
before the "end" on line 66 of matlab/toolbox/stats/eml/randsample.m. I mean, that's completely unsupported, and I'm not recommending it. You'd be doing that at your own risk. Really. Who knows what might happen?).
More Answers (1)
Joel Fernandez on 6 Aug 2018
Edited: Stephen23 on 6 Aug 2018
Hi everyone Can someone help me ? My code error is: "Variable 'sa' is not fully defined on some execution paths" So I'm using this code to SVPWM
function sf =aaa(u)
mag=(u(1)/peak_phase_max) * ts;
if (x>=0) & (x<pi/3)
ta = mag * sin(pi/3-x);
tb = mag * sin(x);
t1=[t0/4 ta/2 tb/2 t0/2 tb/2 ta/2 t0/4];
v1=[0 1 1 1 1 1 0];
v2=[0 0 1 1 1 0 0];
v3=[0 0 0 1 0 0 0];
sf=[sa, sb, sc];