Manipulating filenames using functions

Started by malcolm_graham2002 July 5, 2002
Does anyone know of an easy way (or any way) of manipulating m-file
names using a matlab function.

As a simple example: say I have a Simulink model which runs the m-
file 'file1.m'. Now I also have three other files
called 'file2.m', 'file3.m' and 'file4.m'. What I want to do is
somehow create a loop which runs the simulink model with file1, then
file2, then file3, etc., without manually changing the filename in
Simulink each time (eg. let's say I have 100 files!).

Any ideas?

Thanks,
Mal



Try using the eval command (u might have to use num2str as an arguement inside
the eval command)
malcolm_graham2002 <> wrote: Does anyone know
of an easy way (or any way) of manipulating m-file
names using a matlab function.

As a simple example: say I have a Simulink model which runs the m-
file 'file1.m'. Now I also have three other files
called 'file2.m', 'file3.m' and 'file4.m'. What I want to do is
somehow create a loop which runs the simulink model with file1, then
file2, then file3, etc., without manually changing the filename in
Simulink each time (eg. let's say I have 100 files!).

Any ideas?

Thanks,
Mal
_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this
message will receive your answer. You need to do a "reply all" if you want your
answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:

To Post:

To Leave:

Archives: http://www.yahoogroups.com/group/matlab

More DSP-Related Groups: http://www.dsprelated.com/groups.php3 ---------------------------------



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey,

if you just need to concatenate a number use something like:

newname=[ basename, int2str(num) ];

for basename= 'file' and num= 42 this will result in

newname= 'file42'

If you need to do more complicated formating of the number, the
sprintf()-function may be worth a look. It works like in C.

Regards,

Andre
- --
Andre Vehreschild -- Institute for Scientific Computing, Aachen University
mailto: , phone: ++49- 241- 80- 24874
GnuPG-key available at http://www.sc.rwth-aachen.de/vehreschild
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9KVMwzVF62HujQtARAv0NAJ45wlzUSQnVLxk3MsvoOsndH0iHUACfZlN1
HNH2Ax30dYk3slA1GChl2VM=
=+1Vs
-----END PGP SIGNATURE-----


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey,

if you just need to concatenate a number use something like:

newname=[ basename, int2str(num) ];

for basename= 'file' and num= 42 this will result in

newname= 'file42'

If you need to do more complicated formating of the number, the
sprintf()-function may be worth a look. It works like in C.

Regards,

Andre
- --
Andre Vehreschild -- Institute for Scientific Computing, Aachen University
mailto: , phone: ++49- 241- 80- 24874
GnuPG-key available at http://www.sc.rwth-aachen.de/vehreschild
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9KVMwzVF62HujQtARAv0NAJ45wlzUSQnVLxk3MsvoOsndH0iHUACfZlN1
HNH2Ax30dYk3slA1GChl2VM=
=+1Vs
-----END PGP SIGNATURE-----


Try using the eval command (u might have to use num2str as an arguement inside
the eval command)
malcolm_graham2002 <> wrote: Does anyone know
of an easy way (or any way) of manipulating m-file
names using a matlab function.

As a simple example: say I have a Simulink model which runs the m-
file 'file1.m'. Now I also have three other files
called 'file2.m', 'file3.m' and 'file4.m'. What I want to do is
somehow create a loop which runs the simulink model with file1, then
file2, then file3, etc., without manually changing the filename in
Simulink each time (eg. let's say I have 100 files!).

Any ideas?

Thanks,
Mal
_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this
message will receive your answer. You need to do a "reply all" if you want your
answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:

To Post:

To Leave:

Archives: http://www.yahoogroups.com/group/matlab

More DSP-Related Groups: http://www.dsprelated.com/groups.php3 ---------------------------------



Does anyone know of an easy way (or any way) of manipulating m-file
names using a matlab function.

As a simple example: say I have a Simulink model which runs the m-
file 'file1.m'. Now I also have three other files
called 'file2.m', 'file3.m' and 'file4.m'. What I want to do is
somehow create a loop which runs the simulink model with file1, then
file2, then file3, etc., without manually changing the filename in
Simulink each time (eg. let's say I have 100 files!).

Any ideas?

Thanks,
Mal