How to plot data in Matlab from workspace (Simulink)
조회 수: 80 (최근 30일)
I am currently trying to create a real-time scatter like plot (I want to plot individual points or markers, with which I will later do calculations (finding the mean etc)). My current method of trying is to send the values I have in Simulink to Matlab using the "to Workspace" blocks that I renamed x and y:
I have created a test. file, which includes the following lines:
x = out.x.data;
y = out.y.data;
Unfortnately, nothing is working. I am trying to update the x and y coordinates and plot these two points, but cannot manage it. Can someone please help me?
Ameer Hamza 2020년 11월 12일
You have written 'get' instead of 'out'
x = get.x.data;
%^ replace it with out
Apart from that, your code is correct.
Sara Nadeau 2020년 11월 12일
I believe that the data logged to the workspace is only available after you pause a simulation and when a simulation completes.
If you're working with a version of Simulink that is R2018b or later, you can use a data access callback function to plot data during the simulation: Access Data in a MATLAB Function During Simulation.
Hope this helps!