how to add the input filenames correctly for a .exe in matlab?

8 vues (au cours des 30 derniers jours)
Cathy Chen
Cathy Chen le 1 Fév 2017
Commenté : Cathy Chen le 2 Fév 2017
Hello, anyone can help? I made a .exe file for my matlab functions using the MATLAB COMPILER. While when I use "system" command to run this .exe with inputs specified, I got an error saying the file cannot be read:
Error at line 19 has code like this:
Rrs412=double(hdf5read(fname_oc,'/bands/Rrs_412')).*slope_oc+intercept_oc;
fname_oc is my input file with command:
[status, result] = system(['cal_sss_sat_gom.exe fname_sst fname_oc']);
I am pretty sure the file path and file name are correct, when I type command the following command separately under the command line:
Rrs412=double(hdf5read(fname_oc,'/bands/Rrs_412')).*slope_oc+intercept_oc;
it works perfect.
Below is some code of my function:
==================================================
function SSS = sss_MODIS_NN(fname_sst,fname_oc) slope_oc=1; intercept_oc=0; slope_sst=1; intercept_sst=0; Rrs412=double(hdf5read(fname_oc,'/bands/Rrs_412')).*slope_oc+intercept_oc; Rrs443=double(hdf5read(fname_oc,'/bands/Rrs_443')).*slope_oc+intercept_oc; Rrs488=double(hdf5read(fname_oc,'/bands/Rrs_488')).*slope_oc+intercept_oc; Rrs555=double(hdf5read(fname_oc,'/bands/Rrs_555_ocean')).*slope_oc+intercept_oc; Rrs667=double(hdf5read(fname_oc,'/bands/Rrs_667')).*slope_oc+intercept_oc; sst=double(hdf5read(fname_sst,'/bands/sst')).*slope_sst+intercept_sst;
...
===============================================================
Anyone can help me? I have been struggling on this for a few days... Thank you very much!
Best,
Cathy

Réponses (1)

Walter Roberson
Walter Roberson le 1 Fév 2017
When you build an executable with MATLAB Compiler, it starts running with a current directory that is the place the executable was installed.
  5 commentaires
Walter Roberson
Walter Roberson le 1 Fév 2017
The second output of system() is the text that would have gone to the command window. If you are calculating something numeric and not displaying it then system() is not going to be able to return it.
MATLAB Compiler SDK would be more natural for your problem, if what you want is something that can be called from MATLAB to return a numeric variable.
Cathy Chen
Cathy Chen le 2 Fév 2017
Thank you very much, Walter. I have made my function without any output, now it works perfect using the MATLAB compiler instead of Matlab compiler SDK.
While I came up with another question, currently I can only run this compiled .exe file under the path where the .exe file is stored, which means if I share this .exe with others, they can only use it under the path where they put it. I am wondering, is it possible to put it into my Matlab library, in this way, it would work like an intrinsic .exe file, so I can run it under any working path? Any clue about this? Many thanks!

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB Compiler SDK dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by