Clear Filters
Clear Filters

Problem with input parameters in executable

2 views (last 30 days)
Dimitris M
Dimitris M on 16 Apr 2012
Hello Everyone
I have a serious problem when trying to run an executable (exe file) written in C++. The executable itself works fine and I am able to run it using the " system('dir') " function.
The problem occurs as at the same time when the exe is run through cmd, must be followed by 12 parameters.
The first parameter should be an image, and the rest 11 numbers.
I tried to follow the tutorial found here with no success:
My code looks like:
I=imread('ras_14.tif');
F=[0 1 2 18 125 15 5 0.3 5 1 0.2];
%[stat,res]=system(['C:\Master_Geomatics\Edgeflow-based Anisotropic diffusion\Software\main.exe ',I ,F ]);
The error I am getting is
??? Error using ==> horzcat CAT arguments dimensions are not consistent.
I know that this is caused by the size of the elements within the vector but these are also the inputs that the executable needs so it can run.
The executable I am trying to run can be found here
I would appreciate any help, cause I am stuck !
Thank you in advance

Answers (2)

Walter Roberson
Walter Roberson on 16 Apr 2012
How is the executable receiving the parameters? If it is receiving them on the command line then you need to convert them to text, such as
[stat,res]=system(['C:\Master_Geomatics\Edgeflow-based Anisotropic diffusion\Software\main.exe ', 'ras14.tif', num2str(F) ]);
  2 Comments
Dimitris M
Dimitris M on 16 Apr 2012
Hello and many thanks for your prompt reply.
Know I just followed your instructions and I introduced the parameters as strings. Indeed the parameters should be introduced in the CMD!
Know the following message appaers
C:\Master_Geomatics\Thesis\Segmentation' is not recognized as an internal or external command,
operable program or batch file
This is strange as this is not the correct path to my file !
I tried to set the folder by using the command cd('dir-to-main.exe') ----> so success !
Walter Roberson
Walter Roberson on 16 Apr 2012
You have a space in your path. When you send that through system() it is being interpreted as the end of the command. You would need to quote the command with double-quotes ( "C:\...whatever" ) or else cd to there like you show.

Sign in to comment.


Dimitris M
Dimitris M on 16 Apr 2012
Thank you very much !
That worked just fine !

Tags

Community Treasure Hunt

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

Start Hunting!