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

조회 수: 1 (최근 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