- Firstly, I have created a Simulink model with a Sine wave source block and connected it to a Display block.
- Then I ran the model and tried accessing the Display block's reading from the MATLAB command line using these commands:
Read result from Simulink to GUI with get_param
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
gdz
el 28 de Dic. de 2022
Comentada: gdz
el 13 de En. de 2023
Hi,
I wonder if there is anyway I could read the data from simulink and display it on Matlab GUI. I have Display block in simulink that can display the reading correctly, also I have found out a function called get_param, but it doesn't allow me to read the data from simulink.
May I know if this function get_param works in my case, or I have other way to do it?
Thank you.
0 comentarios
Respuesta aceptada
Bhavana Sapparapu
el 4 de En. de 2023
Editada: Bhavana Sapparapu
el 4 de En. de 2023
Hi,
I understand that you are trying access data from a Simulink model and display it on MATLAB GUI. As you have mentioned, you can use the "get_param" method to achieve this.
Following is a workflow that I have tried using the get_param method:
% Get access to the Simulink runtime object
>> rto = get_param(gcb, 'RuntimeObject');
% Note the current time instance
>> currentTime = rto.CurrentTime
% Display block's reading
>> blockData = rto.OutputPort(1).Data
Following images illustrate the above workflow (window on left is the MATLAB command window and on to the right is the Simulink model in its runtime).
The second screenshot is taken few seconds after the first and I was able to access the real-time reading of the Display block.
Also, if you are trying to display the Simulink data on a GUI in real-time, depending on your use case, you might need to use event listeners as well. To know more about this please have a look at the following MATLAB Answers posts:
1. Updating GUI with data from a Simulink model:
2. Get value from a running Simulink model to MATLAB GUI:
3. More about using event listeners:
4. App Designer to control a Simulink Model and read back model data:
Lastly, you can always use the "Output Port" blocks or the "To Workspace" blocks from Simulink to access data from a model in MATLAB.
I hope this helps.
Más respuestas (0)
Ver también
Categorías
Más información sobre Sources en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!