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

5 visualizaciones (últimos 30 días)
yang xiang
yang xiang el 25 de Mzo. de 2019
Comentada: yang xiang el 26 de Mzo. de 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.

Respuestas (1)

yang xiang
yang xiang el 26 de Mzo. de 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 comentarios
yang xiang
yang xiang el 26 de Mzo. de 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 el 26 de Mzo. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Interactive Model Editing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by