How to define a function to run a particular .m file

Hi,
Probably a simple question but I can't figure it out.
I'm trying to write a kind of shell program which gives users the option to run 26 different codes.
For example, I want to define the function "indcomuse" to run the .m file "a2x1combined.m"
How would I go about doing that? Thanks!

댓글 수: 1

Mason
Mason 2013년 10월 24일
Actually, to clarify, I want a script to run a particular .m file when the user puts in a specific command such as "indcomuse"

댓글을 달려면 로그인하십시오.

답변 (2개)

Wayne King
Wayne King 2013년 10월 24일
You can simply call a defined function inside of another function. As long as both are on the MATLAB path.
If the user passes a function name as a string, or function handle, you can use feval() to run that function
For example:
S = 'mean';
x = randn(10,1);
feval(S,x)

댓글 수: 1

Mason
Mason 2013년 10월 24일
Thanks, but I'm not sure how that fits in to what I'm doing. It probably does and I just don't see it.
I specifically want to define a function that when entered, will just run an already entirely functional (and long) script.

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2013년 10월 25일
Create indcomuse.m that contains the line
a2x1combined

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2013년 10월 24일

답변:

2013년 10월 25일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by