Problem with input parameters in executable

2 次查看(过去 30 天)
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

回答(2 个)

Walter Roberson
Walter Roberson 2012-4-16
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 个评论
Dimitris M
Dimitris M 2012-4-16
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 2012-4-16
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.

请先登录,再进行评论。


Dimitris M
Dimitris M 2012-4-16
Thank you very much !
That worked just fine !

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by