How to prevent a program in matlab to ask the user enter parameters value several times

2 ビュー (過去 30 日間)
I have a problem about deferential evolution program. when i run the code, the program ask to input parameters data (as list ) and when i enter my data the program re ask me to enter the data again by showing the input list again. how can i make the program save my input data just one time for all iterations?

採用された回答

Ameer Hamza
Ameer Hamza 2018 年 8 月 10 日
If you are using input() function in your code to ask for user input then you should either replace input() statements with the constant values in the beginning. If the input() statements are written inside a MATLAB function then you can consider removing them and pass the parameter as input to the function.
  4 件のコメント
Muna Elayyan
Muna Elayyan 2018 年 8 月 11 日
here are the DE for optimization code files.
Ameer Hamza
Ameer Hamza 2018 年 8 月 11 日
The problem is happening because you objfun() is being called several times. It is not a good idea to ask the user for parameter values inside this function. There are following things which you can do
  • You can fix the values yourself
k1 = 1;
k2 = 2;
...
...
  • You can ask for input dialog box in Rundeopt.m file and make it as part of S_struct variable. Then use it in objfun() like this
k1 = S_struct.k1;
k2 = S_struct.k2;
...
...

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by