Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
run another m-file from gui

Subject: run another m-file from gui

From: Chris

Date: 8 Mar, 2009 23:18:01

Message: 1 of 3

Hi,
I'm creating a GUI which will be a catalogue of many m-files relating to a report with 5 chapters, each has its own subchapters with mutliple images in - each from an individual m-file.
When I click the button, I want it to run another m-file which was selected from a series of drop-down menus like a menu tree - chapter -> subchapter -> list of images, run the m-file which will plot the relevant image.
I can't get it to work and can't find any solutions.
Cheers,
Chris

img1={'mfile1.m' 'mfile2.m';'mfile3.m' 'mfile4'.m}; %Relates all images in chapter 1, row 1 is subchapter 1.1 and all images withing, row 2 is 1.2 etc.
    function viewimage(source,eventdata); %callback from button
        val1=get(m1,'value');
        val2=get(m2,'value');
        val3=get(m3,'value');
        switch val1
            case 1
                img=img1(val2,val3);
                run(img) % for chapter 1, subchapter 1, image one - should run mfile1.m
end
end

Subject: run another m-file from gui

From: Chris

Date: 9 Mar, 2009 01:30:03

Message: 2 of 3

I have a part of a solution, for those interested:
%----------------------------------------------------------------------
img1={'mfile1' 'mfile2';'mfile3' 'mfile4'};
%in the callback function:
        switch val1
            case 1
                img=char(img1(val2,val3));
                evalin('base',img)
%-----------------------------------------------------------------------

This works for mfiles in the same folder as the gui, but can i have them in subfolders?




"Chris " <c.j.crawshaw@googlemail.com> wrote in message <gp1jn9$rs2$1@fred.mathworks.com>...
> Hi,
> I'm creating a GUI which will be a catalogue of many m-files relating to a report with 5 chapters, each has its own subchapters with mutliple images in - each from an individual m-file.
> When I click the button, I want it to run another m-file which was selected from a series of drop-down menus like a menu tree - chapter -> subchapter -> list of images, run the m-file which will plot the relevant image.
> I can't get it to work and can't find any solutions.
> Cheers,
> Chris
>
> img1={'mfile1.m' 'mfile2.m';'mfile3.m' 'mfile4'.m}; %Relates all images in chapter 1, row 1 is subchapter 1.1 and all images withing, row 2 is 1.2 etc.
> function viewimage(source,eventdata); %callback from button
> val1=get(m1,'value');
> val2=get(m2,'value');
> val3=get(m3,'value');
> switch val1
> case 1
> img=img1(val2,val3);
> run(img) % for chapter 1, subchapter 1, image one - should run mfile1.m
> end
> end

Subject: run another m-file from gui

From: Zhelyazko

Date: 22 May, 2009 02:33:02

Message: 3 of 3

You can change the current working directory to the one that you m files that you want to execute are
evalin('base','cd(''c:\'')');

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us