"Lookup Table Dynamic" block not updating when table values are changed inside a triggered function
3 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I am having an interesting issue with the "Lookup Table Dynamic" block. I am trying to change the ydata vector of the lookup table from within a triggered function. The table output does not appear to be updating in the simulation. I have attached an example that demonstrates the problem, and an image that illustrates the example.
In the example, the model simTRIGGERED is executed repeatedly. This model runs function funTRIGGERED, from which I modify the values of the table's ydata vector. This is done through variables in the global struct "data". I expected that because the lookup table is "dynamic," it would automatically update its ydata as the data.y_table is changed. However, the scope ("Scope1") shows that the table's output does not change. But, when the plot() function is used, it looks like the data.y_table vector actually was changed.
Why is the dynamic lookup table not updating while the simulation runs? Is there some problem with how my simulation/functions are organized?
Best Regards, James
0 件のコメント
採用された回答
Orion
2014 年 12 月 16 日
Hi,
Actually, the From workspace blocks are evaluated at the init phase of the simulation, not during even if you change the data with your script.
You need to update the model at every change of your data if you want the new values to be loaded inside the model.
You can do this by adding a line in the function funTRIGGERED :
function funTRIGGERED(varin)
global data;
data.y_table(data.i_sample) = data.i_sample;
data.i_sample = data.i_sample + 1;
set_param(bdroot,'SimulationCommand','Update');
end
With this new line, the entire model is updated : From Workspace, Constant,...
This works, but it is kind of risky. Also, if you are running a big model, it will be really, really slow.
Instead of using this method, you should add some outputs (data.y_table,...) to funTRIGGERED and use connect them directly in simulink to your lookup table.
2 件のコメント
Marine
2014 年 12 月 16 日
I have nearly the same problem, but from a matlab function. Can this method work with matlab functions too ? Or do you know how to solve my problem ?
Orion
2014 年 12 月 16 日
you probably can do the same with a matlab function , but probably with another syntax and condition of execution because the behaviour is different of an interpreted matlab function . Remember that a matlab function is a "real" simulink block, tha t is not the case of the interpreted which calls an external file.
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Event Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!