Does set_param have a numerical accuracy limit? If so, what can I do to solve the problem?
古いコメントを表示
Hello,
I recently conceived a MATLAB/Simulink programming problem for my students. The problem was to adapt the coefficients of a 2nd order linear dynamical system such that the step response best fits a given function.
The structure shoud be as follows (see attaced files OptDynSysTest1.m, simuSys.m and DynSystem.slx, sprawsoll.m in setparamproblem.zip):
When the main file (OptDynSysTest1.m) is launched with a handle to the desired step response (@sprawsoll), the sampling points (for example (0:0.1:10)) and an ititial guess for the three system coefficients (for example [1,1,1]), the program opens DynSystem.slx and tries to optinize those coefficients to best fit the step response of the system to the given function. For this purpose the procedure lsqcurvefit is used. The objective function is represented by simuSys.m. This function simulates the system by setting the actual parameters to DynSystem.slx using set_param and the calling sim.
In a second version of this problem, I do not use Simulink to simulate the system but I'm using lsim instead (see attaced files OptDynSysTest3.m, simuSys3.m and DynSystem.slx, sprawsoll.m in setparamproblem.zip).
The problem is that this program works fine and finds the optimal step resonse approximation whereas the version using Simulink sticks in the first iteration saying that the initial guess is the optimum. Regardedless what the initial guess is!
After a couple of hours of analysis I found out what the reason is.
The problem is set_param!!!
This function passes parameters in a numerically inexact way. For example the parameter 2.001 is passed exactly whereas the parameter 2.0000001 will be simply 2 for Simulink. This is the reason why the optimizaton procedure doesn't work, because in the beginning the changements in the parameter values are very small. Since those small changements "disappear" when passed to Simulink by set_param, the optimization algorithm immediately finds a zero gradient and stops saying that this is an optimum.
My questions: Is this a set_param bug? How can I overcome this set_param problem?
Sincerily Ottmar Beucher
2 件のコメント
Sainath Varikuti
2015 年 8 月 21 日
Hi Ottmar,
You can use get_param(gcb,'ParameterName') to get the value of the parameter. Do you see the truncation in the value returned by get_param?
Regards,
Sainath
Ottmar Beucher
2015 年 9 月 16 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Manual Performance Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!