How to call/include/load one m file in another m file?

조회 수: 19 (최근 30일)
Micky
Micky 2013년 4월 12일
댓글: Aboli Ruikar 2017년 9월 26일
I have a huge matlab program (.m file) which is a higher level model of some design and this program has bunch of variables. I want to store these variables in different/separate matlab file which should be .m file. So, I want in this way because I want to make changes with the variable values and run the original matlab program, basically run experiments with the model with new variable values. I know we can store varibles in mat file but it is not writable. So, basically my question comes down to this, I can store varibales in a separate m file but everytime I run the original program, how can I include and load the variables (m file) in the original matlab program file (m file)?
  댓글 수: 4
Micky
Micky 2013년 4월 16일
Thanks Matt, it solved my problem.
Aboli Ruikar
Aboli Ruikar 2017년 9월 26일
Thank you !!

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

답변 (1개)

per isakson
per isakson 2013년 4월 12일
편집: per isakson 2013년 4월 12일
There are many more or less smelly alternatives, one of which is a "data class". Example:
classdef MyInput
properties ( Constant = true )
p01 = 17;
end
end
refer to the data in your huge program with
>> MyInput.p01
ans =
17
This approach helps make your code a bit more readable.
"... make changes with the variable values ..." - how many variable?

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by