MATLAB Answers


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


Show 1 older comment

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.

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

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

Log in to comment.

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.


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 .

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

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

Log in to comment.

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.


Log in to comment.

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 Academy

New to MATLAB?

Learn MATLAB today!