Sizes mismatch: [1][6] ~= [1][1]

2 次查看(过去 30 天)
xiaofu zhang
xiaofu zhang 2019-5-1
I have use the function code as follow and use the MATLAB CODER to convert it to C code.But it has some error in the 'find' function.
The front of the function can be ignored, and the 'OC' is a matrix,'sci' is a integer. I just use the 'find' function and has the error as follow. The 'find' function i used in other funcion is right. The process of MATLAB CODER including generating trial code and building MEX is no error ,just in the running test file with MEX.
Could you give me some advice?Thanks a lot!
Error using SelectLeader (line 17)
Sizes mismatch: [1][6] ~= [1][1].
1function leader = SelectLeader(obj)
2 leng=length(obj.swarm);
3 sc=0;
4 GI=zeros(1,leng);
5 for i=1:leng
6 GI(i)=obj.swarm(i).GridIndex;
7 end
8 OC = unique(GI);
9 N = zeros(size(OC));
10 for k = 1:length(OC)
11 N(k) = length(find(GI==OC(k)));
12 end
13 P = exp(-obj.beta*N);
14 P = P/sum(P);
15 sci = RouletteWheelSelection(P);
16 sc = OC(sci);
17 SCM=find(GI==sc);
18 smi=randi([1 length(SCM)
19 sm = SCM(smi);
20 leader = obj.swarm(sm);
21 end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by