"Lookup Table Dynamic" block not updating when table values are changed inside a triggered function

조회 수: 2 (최근 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

채택된 답변

Orion
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
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
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개)

James Potter
James Potter 2014년 12월 16일
Thanks a lot, Orion. Just what I needed.

카테고리

Help CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by