replace the function "randperm" into code from embedded block SIMULINK

1 次查看(过去 30 天)
hi, I need to generate a c code from the next code wrote on an embedded editor from embedded block from simulink, but randperm is not supported by code generation, is there some way to do it?
thanks for you support
Size = 100
n = 50
pop = zeros(Size,n);
pop(1,:) = (1:n);
for k = 2:popSize
pop(k,:) = randperm(n);
end
  1 个评论
Emmanuel Luevano
Emmanuel Luevano 2012-11-20
btw, if I use eml.extrinsic to execute it, I understand that the operation is performed externally, but, it affect my code when this is done?

请先登录,再进行评论。

采纳的回答

Jan
Jan 2012-11-20
randperm() is actually:
[~, p] = sort(rand(1,n))
Does this work in code generation?
In the current Matlab version, randperm uses the smarter Fisher-Yates-Shuffle, when 2 inputs are used. Would a corresponding C-Mex function work: FEX: Shuffle ?

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by