I have written an mfile that creates a user selectable list of other mfiles, the list is numbered and users input a number between 1 and whatever to select the mfile they want to open. The problem I have is that after the user selection has been made I cannot use the 'run' command to open the selected mfile as it is stored with a cell array. Say for example the user selects the first mfile in the list by entering '1', this means the file I want to open is stored in the firt row of the cell array eg (cell_array{1}) In my script at the moment as the last line I have;
run (char(cell_array{1}))
however this doesnt work as run will only accept a filname or command as an input.
I can use open(char(cell_array{1})) although this interupts the automation of the process im trying to create.
Does anyone have any ideas how I can do this? any help would be appreciated as to me it seems like a bit of a stupid problem to have.
Comments
menu = {'option_1', 'option_whatever_2'}
m = input('Enter your option: ');
switch m
case 1
run (menu{1})
case 2
run (menu{2})
otherwise
disp('Unknown method.')
end
And you have two more m-files, with appropriate names:
function option_1
disp('hello, this is opt. 1')
function option_whatever_2
disp('hello, this is option 2')
Maybe these additional examples could clarify other possibilities:
http://www.matrixlab-examples.com/cell-arrays.html
http://www.matrixlab-examples.com/trigonometry.html