Matlab file converted into standalone application and given input arguments

Hi I have converted a Matlab program into standalone program .exe. when I run .exe file in windows command prompt it return the following error
1. two many input arguments // when I give two inputs which is supposed to be 2. the first argument should have as many column as input variables as many rows as independent set of input values // when I give one input.
I used the command to build standalone : "mcc -mv myfile.m -a datfile.fis" ----------- building process is ok. But when I run with this command " myfile.exe 2.0 20.2 "in windows prompt it gives above errors. My program takes two inputs and gives one output. I have run Matlab tutorial magicsquare.m to convert magicsquare.exe on the same computer and works fine

4 件のコメント

Jurgen
Jurgen 2013 年 1 月 20 日
what exactly did you type in the command prompt?
Image Analyst
Image Analyst 2013 年 1 月 20 日
And in the opening code of your program (OpenFcn if you used GUIDE), let's see how you handled inputs in the input arg list. Did you hard code specific variables in there, or did you use varargin? If you used varargin, let's see how you extracted variables from it.
Jian Dong
Jian Dong 2013 年 1 月 21 日
I type the following command on windows command prompt
c:\>myfile.exe 2.0 20.2 // I am supposed to give two inputs in double such as 2.0 and 20.2 assume myfile.exe is in my root directory
Jian Dong
Jian Dong 2013 年 1 月 21 日
編集済み: Walter Roberson 2013 年 1 月 21 日
I am not using GUIDE. My code as follows
function out = myfile (x); % get two inputs in double
fismat =readfis('myfile.fis'); % read fuzzy file
out=evalfis (x,fismat); % result after defuzzificztion ----- In matlab I am given input in the following format and it is working fine------- myfile([2.0 20.2])

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2013 年 1 月 21 日

0 投票

Arguments passed to a compiled executable are in character format. If you need numeric values, convert the inputs to numeric.
Also, spaces normally mark the end of each argument, so if you want 2.0 20.2 to be a single vector, you need to expect multiple inputs and convert the inputs into a numeric vector.

10 件のコメント

Jian Dong
Jian Dong 2013 年 1 月 21 日
Thanks Mr. Walter for your reply, I would highly appreciate if you tell the procedure how can I convert the inputs into numeric
and how can I convert the inputs into a numeric vector, Many thanks
Jian Dong
Jian Dong 2013 年 1 月 21 日
編集済み: Walter Roberson 2013 年 1 月 21 日
I have used str2double() function to convert inputs to double before compilation.However I could not get your second part that is related to inputs into numeric vector. after compilation I tried to run on command prompt and I am getting the same error. now my code is as follows:
function out = myfile (x); % get two input
fismat =readfis('myfile.fis'); % read fuzzy file
out=evalfis (x,fismat); % result after defuzzificztion
if (isdeployed)
x = str2double(x);
fismat = str2double(fismat);
out=evalfis (x,fismat); % result after defuzzificztion
end
function out = myfile(varargin)
if ischar(varargin{1})
x = arrayfun(@(C) str2double(C{1}), varargin);
else
x = varargin{1};
end
fismat =readfis('myfile.fis');
out=evalfis (x,fismat);
end
Jian Dong
Jian Dong 2013 年 1 月 21 日
Thanks: but now it gives the following error
Error using evalfis (line 63) The first argument should have as many columns as input variables and as many rows as independent sets of input values.
Error in myfile (line 8) out=evalfis (x,fismat); I am getting same errors in Matlab itself and after converting standalone in command prompt. Any idea?
Walter Roberson
Walter Roberson 2013 年 1 月 21 日
編集済み: Walter Roberson 2013 年 1 月 21 日
Just after the assignment to fismat, please add disp('x size') disp(size(x)) disp('x value') disp(x) disp('fis size') disp(size(fismat))
and show us the resulting output.
Jian Dong
Jian Dong 2013 年 1 月 21 日
編集済み: Jian Dong 2013 年 1 月 21 日
Here it is
x size
1 2
x value
8 40
fis size
1 1
Error using evalfis (line 63)
The first argument should have as many columns as input variables and
as many rows as independent sets of input values.
Error in myfile (line 13)
out=evalfis (x,fismat);
This time i have given input 8.0 and 40.0
Okay. Just before the evalfis() please add
disp(getfis(fismat, 'numinputs'))
disp(getfis(fismat))
Jian Dong
Jian Dong 2013 年 1 月 21 日
Tons of thanks it is working well now. sorry it was my mistake. The .fis file was linked with 4 inputs. I just replaced with 2 now. you made my life easy many Thanks again. Please just let me know where I have to change if I use 4 inputs .
Walter Roberson
Walter Roberson 2013 年 1 月 21 日
The code I showed above would not need any change: just type four values on the command line.
Jian Dong
Jian Dong 2013 年 1 月 21 日
That's great. Thanks you very much for your help. I think you are the right person I can discuss one more thing. I have developed one fuzzy model in Matlab and converted into Java package through Matlab Java builder JA. but when I run this converted fuzzy model with my other java module . It takes unbelievable memory. I have run this model on high performance machine with 400 GB RAM but still get memory allocation problem. That's why I am trying to run now with standalone application. what do you think If I run standalone fuzzy model with my other java module in java, will it takes same amount of memory? Please help in this regard

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2013 年 1 月 21 日
Try it this way
function out = myfile(varargin) % get two inputs in double
x = str2double(deal(varargin))
% Now use x as an array in the rest of your function.

カテゴリ

ヘルプ センター および File ExchangeCall Java from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by