Running one M file inside other

2 ビュー (過去 30 日間)
dusan
dusan 2012 年 7 月 17 日
Is it possible to run one m file inside other. for example: I have Constant.m file that I need to run every time before executing any other m file (like a1.m as shown):
Constant.m: g=9.80665; Pi=3.1415926535897932384626433832795;
a1.m: M=142; Fp=(((2*Pi)^2)/g)*M
Is it possible to somehow include Constant.m file on top of a1.m that automaticaly runs Constants.m file.
Thank you in advance Dusan

回答 (2 件)

Siva Mohan Sundara
Siva Mohan Sundara 2012 年 7 月 17 日
you include file a1.m inside the file Constant.m as follows
a1; g=9.80665; Pi=3.1415926535897932384626433832795;
Now it will automatically execute a1.m first whenever the file Constant.m is executed.

Siva Mohan Sundara
Siva Mohan Sundara 2012 年 7 月 17 日
Sorry I misunderstood your question. In a similar way you can include the file Constant.m inside a1.m as
Constant; % followed by code of a1.m

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by