Tags: box, click, demo, gui, load, m-file, matlab, programming, run, tochose, user

Load and run M-file from GUI

On Programmer » Matlab

3,354 words with 2 Comments; publish: Wed, 07 May 2008 17:12:00 GMT; (20062.50, « »)

Hi,

I'd like to load & run an M-File from a GUI :

I have a list box with a set of demo M-File, then I want the user to

chose one, click the "Start" button, and the selected file to be

executed. I tried that :

contenu = get(handles.txt_fichier,'String');

fichier = contenu(1);

disp(fichier);

run(fichier);

and I got that :

---

'demo1.m'

? Function 'eq' is not defined for values of class 'cell'.

Error in ==> eq at 18

[varargout{1:nargout}] = builtin('eq', varargin{:});

Error in ==> run at 24

if ispc, script(find(script=='/'))=''; end

Error in ==> selecteur_de_demo>but_lancer_Callback at 120

run(fichier);

Error in ==> gui_mainfcn at 75

feval(varargin{:});

Error in ==> selecteur_de_demo at 44

gui_mainfcn(gui_State, varargin{:});

? Error while evaluating uicontrol Callback.

---

what should I do ?

thanks for any help !

All Comments

Leave a comment...

  • 2 Comments
    • baronnet.matlab.todaysummary.com.gmail.com wrote:

      >

      > Hi,

      > I'd like to load & run an M-File from a GUI :

      > I have a list box with a set of demo M-File, then I want the user

      > to

      > chose one, click the "Start" button, and the selected file to be

      > executed. I tried that :

      > contenu = get(handles.txt_fichier,'String');

      > fichier = contenu(1);

      > disp(fichier);

      > run(fichier);

      > and I got that :

      > ---

      > 'demo1.m'

      > ? Function 'eq' is not defined for values of class 'cell'.

      > Error in ==> eq at 18

      > [varargout{1:nargout}] = builtin('eq', varargin{:});

      > Error in ==> run at 24

      > if ispc, script(find(script=='/'))=''; end

      > Error in ==> selecteur_de_demo>but_lancer_Callback at 120

      > run(fichier);

      > Error in ==> gui_mainfcn at 75

      > feval(varargin{:});

      > Error in ==> selecteur_de_demo at 44

      > gui_mainfcn(gui_State, varargin{:});

      > ? Error while evaluating uicontrol Callback.

      > ---

      > what should I do ?

      > thanks for any help !

      >

      It's a little hard to tell from the French (sorry), but I think you

      need to change the second line to:

      fichier = contenu{1};

      in order to get the string instead of the string inside of a cell.

      Then you can run it with:

      eval(fichier);

      I haven't tested my response, so I may be incorrect about some part

      of it. Hope this helps.

      Ken Fleisher

      #1; Wed, 07 May 2008 17:13:00 GMT
    • thanks ken, you got it !

      with {1} and run it works great.

      and by the way, contenu means content, fichier menas file.

      Francois

      Ken Fleisher wrote:

      > baronnet.matlab.todaysummary.com.gmail.com wrote:

      >

      > It's a little hard to tell from the French (sorry), but I think you

      > need to change the second line to:

      > fichier = contenu{1};

      > in order to get the string instead of the string inside of a cell.

      > Then you can run it with:

      > eval(fichier);

      > I haven't tested my response, so I may be incorrect about some part

      > of it. Hope this helps.

      > Ken Fleisher

      #2; Wed, 07 May 2008 17:15:00 GMT