1

I don't know if this is possible but i want to execute an external matlab script inside another one already compiled by using the deploytool.

I ask via uigetfile for an m-file and then i use the run function inside my script; i already checked that when running inside matlab the script runs properly.

[FN,PN]=uigetfile('*.m','Get material data in matlab format');
mmdata=fullfile(PN,FN);
run(mmdata);

When running the deployed programm i get the following error:

Error using ==> run at 65
D:\Mat_Data.m not found
MATLAB:run:FileNotFound

The file does exists.

Sorry if this has been already answered! I was unable to find the relevant posts on this board.

user2751649
  • 89
  • 1
  • 1
  • 8
  • 1
    To isolate the error, could you try to read the first line? Simply put in this line and recompile. `fid = fopen(mmdata);disp(fgetl(fid));fclose(fid);` If this succeeds, we know at least that your tool has the sufficient rights to read the file. Otherwise it could be some file system restriction. – Daniel May 20 '14 at 19:14
  • 1
    I already did it, and the first line of the m-file is displayed but the same error when using run appears. – user2751649 May 20 '14 at 19:27
  • I found an answer: http://stackoverflow.com/questions/7409606/running-an-m-file-from-a-matlab-compiled-function Thinking about this limitation, they prevent you from deploying a full functional Matlab interpreter. If you need such features you probably need a full Matlab installation. – Daniel May 21 '14 at 09:11
  • I just added this answer to the linked question: You can read read an m file, line by line and execute each line with the eval() function. There are restrictions on the format of the m file (no line breaks for example, each line must contain a complete MATLAB statement) but it does work and can add to your run time environment inside the compiled application. I use this technique to allow users to define configuration and data files for a compiled application I have developed. Clearly, if your end user provides a poorly formed m file to evaluate, you will end up with difficult to resolve bugs. – Nigel Davies Feb 05 '15 at 11:42

0 Answers0