Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Matlab file converted into standalone application and given input arguments

Asked by Jian Dong on 20 Jan 2013

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 Comments

Image Analyst on 20 Jan 2013

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 on 21 Jan 2013

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 on 21 Jan 2013

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])
Jian Dong

Products

No products are associated with this question.

2 Answers

Answer by Walter Roberson on 21 Jan 2013
Accepted answer

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 Comments

Jian Dong on 21 Jan 2013

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 on 21 Jan 2013

The code I showed above would not need any change: just type four values on the command line.

Jian Dong on 21 Jan 2013

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

Walter Roberson
Answer by Image Analyst on 21 Jan 2013

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.

0 Comments

Image Analyst

Contact us