run a script inside another script

4 ビュー (過去 30 日間)
André Pacheco
André Pacheco 2013 年 1 月 7 日
Hello,
I have made a script called "EPSO" that do a lot of calculations and in the end it gives the global_best_solution. I want to test the strength because if i run 100 times the global_best_solution should be always the same. So i've made a script that run this script and should keep the global_best_solution in each iteration.
for i=1: 3
EPSO;
solutions(1,i)=global_best_solution;
end
The problem is that this doesn't keep the result each time i run it. Thanks in advance
  1 件のコメント
per isakson
per isakson 2013 年 1 月 7 日
Could it be that the variable, i, occurs in ESPO?

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

採用された回答

per isakson
per isakson 2013 年 1 月 7 日
編集済み: per isakson 2013 年 1 月 7 日
That's what functions are for.
Convert EPSO to a function
function global_best_solution = ESPO_fcn( indata, if, needed )
the code of ESPO
end
and next write a script
N = 3;
solutions = nan( 1, N ); % pre-allocate memory
for ii = 1 : N
solution( 1, ii ) = ESPO_fcn( indata, if, needed );
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by