MATLAB: How can I fix the error “size inputs must be scalar”

MATLABMATLAB Compilersize inputs must be scalar

Hi all, can someone please explain me how can I fix the error "size inputs must be scalar"?
When I run the code in matlab it works correctly but when i run the compiled exe I obtain this error:
Error using randperm
Size inputs must be scalar.
Error in randsample (line 162)
Error in 'mycode' (line .'indexesWith0=randsample(1:n-sumboo,nToAnalyze-sumboo); % '..)
MATLAB:NonScalarInput
nToAnalyze=options.nToAnalyze;
if isempty(nToAnalyze)
Exclude='';
else
if nToAnalyze >n
error(['nToAnalyze must be smaller or equal than ' num2str(n)])
end
boo=double_y ==1; %






notboo=~boo; %
sumboo=sum(boo); %
seq=1:n; %
indToExtractWith0=seq(notboo); % indexes of units which have 0
indexesWith0=randsample(1:n-sumboo,nToAnalyze-sumboo); %
UnitsToAnalyzeWith0=indToExtractWith0(indexesWith0); %
UnitsToanalyze=[seq(boo) UnitsToAnalyzeWith0]; %
Exclude=setdiff(seq,UnitsToanalyze); %
end
thank you, D.

Best Answer

"The input arguments you pass to your executable from a system prompt will be received as character vector input. Thus, if you expect the data in a different format (for example, double), you must first convert the character vector input to the required format in your MATLAB code. For example, you can use STR2NUM to convert the character vector input to numerical data."
My guess is that you called your application with a multi-digit number as input and used that as part of the second input for your call to randsample, something like:
randsample(1000, '99'-50)
As the documentation says, you probably want something along the lines of:
randsample(1000, str2num('99')-50)