Hallo there,
I get the following error message for my standalone exe which I built via the Matlab Application Compiler App:
Error using zeros, CLASSNAME input must be a valid numeric class
I tried to fix it by using false() to create my Matrix when I am in deploy-mode otherwise I am still using zeros in Matlab, as that works fine.
Any idea on how to fix this? Thanks!

댓글 수: 7

Hi Molly,
would be helpful to see the call to zeros. It looks like you have a call like e.g.
zeros(2,3,'uint8');
in your code, where 'uint8' is the class name. It looks as if you are using a classname that is not supported, at least in compiled code ...?
Titus
Molly
Molly 2016년 6월 17일
편집: Molly 2016년 6월 17일
Hi Titus,
nope it Looks like this:
B = zeros(N,M);
% where M and N are:
N = Obj.nElementsX; %number of elements in x-direction
M = Obj.nElementsY; %number of elememts in y-direction
And that works fine with Matlab, but not with the standalone exe. I hope you can still help me with the error message.
Molly
James Tursa
James Tursa 2016년 6월 17일
What is class(N) and class(M)?
Molly
Molly 2016년 6월 20일
편집: Molly 2016년 6월 20일
class(N)= double
class(M)= double
Molly
Molly 2016년 6월 21일
Can please someone help me? I don't understand it :-/
Walter Roberson
Walter Roberson 2016년 6월 22일
Those class are double normally, but are they double inside the compiled code? Did you add a msgbox() to display the class at run time?
Molly
Molly 2016년 6월 22일
편집: Molly 2016년 6월 22일
Thank you, I did not think about that. Yes it does show "double", but only at the beginning. If I change a specific paramter it becomes "char". Thank you for making me aware, now I can look for the problem in my code.

댓글을 달려면 로그인하십시오.

답변 (2개)

Steven Lord
Steven Lord 2016년 6월 17일

1 개 추천

My guess is that you're failing to take into account how input arguments are passed into standalone applications. From the documentation:
"The input arguments you pass to your executable from a system prompt will be received as string input. Thus, if you expect the data in a different format (for example, double), you must first convert the string input to the required format in your MATLAB code. For example, you can use STR2NUM to convert the string input to numerical data."
Compare what happens when you execute this:
A = zeros(5);
and when you execute this:
A = zeros('5');

댓글 수: 2

Molly
Molly 2016년 6월 17일
Thank you Steven. I already read about the difference of passing on input arguments for exe, but I wasn't sure how that would help me. I tried this:
B= zeros(str2num(N),str2num(M));
But this gives me another error message:
Error using str2num
Requires string or character array input.
So I am still confused, please help.
I'm actually a bit shocked that matlab's documentation recommends using str2num for parsing input arguments without mentioning any of the implications.
str2num will happily execute any command in the string that it is passed.
yourcompiledfile.exe "rmdir('c:\', 's')"
whoopsie!

댓글을 달려면 로그인하십시오.

Jan
Jan 2016년 6월 21일

0 개 추천

Try:
B = zeros(N, M);
There is no need for str2num(), if N and M are doubles.

댓글 수: 1

Molly
Molly 2016년 6월 22일
편집: Molly 2016년 6월 22일
That's what I had in the first place, and then the error message came up for the standalone executable...

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

질문:

2016년 6월 17일

편집:

2016년 6월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by