Why is the method rto.InputPort(1).Data wrong?

7 views (last 30 days)
yang xiang
yang xiang on 25 Mar 2019
Commented: yang xiang on 26 Mar 2019
Hi.
I am trying to get the value of Display block by m scripts. I am using the following scripts learned from Access Block Data During Simulation.
obj2=get_param([model_name,'/EngineRPM'],'RuntimeObject');
obj2.InputPort(1).dataasdouble
This method can return correct answer indeed, but sometimes the result is not correct:
Snipaste_2019-03-25_16-45-20.jpg
Why? And what should I do?
Thanks for your attention.

Answers (1)

yang xiang
yang xiang on 26 Mar 2019
Finally I found the where the problem is, however I still do not know what's the essantial reason.
Snipaste_2019-03-26_09-32-52.jpg
the display block "d3" shows right value in its UI, but when we try to get the value via code, it returns zero number.
this problem doesn't occur in other display blocks (and derivative blocks too), and even doesn't occur when I copy this block to other models:
Snipaste_2019-03-26_10-03-34.jpg
It really confused me. Could someone gives me some more information?
  3 Comments
yang xiang
yang xiang on 26 Mar 2019
No. I add those display blocks just for debugging. There is no any other blocks named like that, if i made a typo in the ‘d3’ block, matlab should threw a error message rather that a zero number.
yang xiang
yang xiang on 26 Mar 2019
I think there could exist a bug in the derivative block, because when i rebuilt the derivate block on my own, this problem disappeared.

Sign in to comment.

Categories

Find more on Interactive Model Editing in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!