How can I automize my code?

Hi guys!,
I need some help. I am working on a code that is made of different m.files
Everytime I insert a value for the parameter T in an m.file it uses all the other to calculate a variable.
I need to register the value of the variable calculated for differenct values of T and I am looking for a way to make this automaticly.
I would like make the code able to run that calculation in a range of T insted of putting the T value by hand each time.
Can somebody explain me how?
Thank you

3 件のコメント

per isakson
per isakson 2015 年 2 月 19 日
編集済み: per isakson 2015 年 2 月 19 日
"code that is made of different m.files" &nbsp are they scripts or functions?
Answer:
T_values = [122,24,89];
for T = T_values
R = foo( T );
fprintf( '%12.4f, %12.4f', T, R );
end
Dvdiz
Dvdiz 2015 年 2 月 20 日
They are all function, except run.m that call all the other m.file
per isakson
per isakson 2015 年 2 月 20 日
  • What's the problem?
  • "register the value of the variable calculated" &nbsp I don't understand
  • I need a more detailed description to be able to help

サインインしてコメントする。

回答 (1 件)

Rafi
Rafi 2015 年 2 月 20 日

0 投票

From what I understood you want to make the variable T global (to use it with other functions as well). What I suggest is you then to have a look at the link http://nl.mathworks.com/help/matlab/ref/global.html. And maybe use other variables than T in each of your scripts: like global T1, global T2, etc. if they have different values.

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

タグ

質問済み:

2015 年 2 月 19 日

回答済み:

2015 年 2 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by