Error when building the Mex Function using Matlab Coder: " The size to the left is the size of the left-hand side of the assignment."

1 visualizzazione (ultimi 30 giorni)
I'm using Matlab Coder in Matlab-r2014b and I have the following problem. I'm reporting here a sample code with structure and type of variables similar to my real one.
1) The script that calls the entry-point
clear all
N=3 ;
Res=alg(N);
2) The entry-point
function val=alg(N)
coder.varsize('matrixfinal');
matrixfinal=zeros(1,3*N+2);
profindex=randi(N+1,2^(N-1),1);
for s=1:10
coder.varsize('matrix');
matrix=zeros(1,3*N+2);
for k=1:2^(N-1)
if profindex(k)==N-1
matrix=[matrix; randi(1,1,3*N+2)];
end
end
if size(matrix,1)>1
matrix(1,:)=[];
end
for k=1:size(matrix,1)
count=0;
for h=1:size(matrixfinal,1)
if sum(matrix(k,2+2*N:3*N)==matrixfinal(h,2+2*N:3*N))==N-1
count=1;
matrixfinal(h,3*N+1)=matrixfinal(h,3*N+1)+matrix(k,3*N+1);
matrixfinal(h,3*N+2)=matrixfinal(h,3*N+2)+matrix(k,3*N+2);
end
end
if count==0
matrixfinal=[matrixfinal; matrix(k,:)];
end
end
end
if size(matrixfinal,1)>1
matrixfinal(1,:)=[];
end
val=matrixfinal(1,1);
end
When I try to built the Mex Function I get the following error
??? Size mismatch (size [1 x :?] ~= size [2 x :?]).
The size to the left is the size of the left-hand side of the assignment.
Error in ==> alg Line: 29 Column: 9
The line of the error is `matrixfinal=[matrixfinal; matrix(k,:)];`
How can I solve this problem? All the code lines are strictly necessary and cannot be changed.

Risposte (0)

Categorie

Scopri di più su MATLAB Coder in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by