From: Teodor on
Hello! Can anyone help me with something?
My problem is that I have to run some functions from my directory without typing:
run function_name.m
For example I have a list in excel with all the functions that are in my directory and I made a code in matlab that reads the excel file and puts all the functions in an array.
Then for the array{1,1} I will have a variable='function_name' that I will want to run.
How can I say: run variable in matlab and the function_name from my directory corresponding to the variable=function_name will run?
Ex:
I have in my directory test.m
var = 'test'

run var -> this will not work

Help please!
Thanks in advance!
Alexandra
From: James Tursa on
"Teodor " <teodoralexandra(a)yahoo.com> wrote in message <hna77p$bqc$1(a)fred.mathworks.com>...
> Hello! Can anyone help me with something?
> My problem is that I have to run some functions from my directory without typing:
> run function_name.m
> For example I have a list in excel with all the functions that are in my directory and I made a code in matlab that reads the excel file and puts all the functions in an array.
> Then for the array{1,1} I will have a variable='function_name' that I will want to run.
> How can I say: run variable in matlab and the function_name from my directory corresponding to the variable=function_name will run?
> Ex:
> I have in my directory test.m
> var = 'test'
>
> run var -> this will not work
>
> Help please!
> Thanks in advance!
> Alexandra

doc eval

James Tursa
From: Walter Roberson on
Teodor wrote:

> I have in my directory test.m
> var = 'test'
>
> run var -> this will not work

run(var)
From: Teodor on
Walter Roberson <roberson(a)hushmail.com> wrote in message <hna7sl$jqd$3(a)canopus.cc.umanitoba.ca>...
> Teodor wrote:
>
> > I have in my directory test.m
> > var = 'test'
> >
> > run var -> this will not work
>
> run(var)

I have tryoed to put this command, but it doesn't work, it gives an error that it cannot find the function_name.m....but I have it in my working directory....
From: Pekka Kumpulainen on
"Teodor " <teodoralexandra(a)yahoo.com> wrote in message <hna9qk$sj8$1(a)fred.mathworks.com>...
> Walter Roberson <roberson(a)hushmail.com> wrote in message <hna7sl$jqd$3(a)canopus.cc.umanitoba.ca>...
> > Teodor wrote:
> >
> > > I have in my directory test.m
> > > var = 'test'
> > >
> > > run var -> this will not work
> >
> > run(var)
>
> I have tryoed to put this command, but it doesn't work, it gives an error that it cannot find the function_name.m....but I have it in my working directory....

If your var = 'test';
Both eval(var) and run(var) should work. They work here.
If var = 'test.m', they don't work.

Are you sure your MATLAB is in the directory you think?
Try which(var) or which test.
 |  Next  |  Last
Pages: 1 2
Prev: jpeg200 code
Next: ismember() help