Plt.plot(accelZ, 'go-', label='Raw Z Acceleration') Plt2.ticklabel_format(useOffset=False) #Compel matplotlib not to autoscale ot(accelY, 'b^-', label='Raw Y Acceleration') Plt2 = plt.twinx() #Create a new object of plt2 Plt.plot(accelX,'ro-', label='Raw X Acceleration') #Set the line plot Plt.ylabel('Axis Acceleration') #Label the y axis #plt.ylim(0,1000) #Set the limit on the y axis Plt.ion() #Tell matplotlib you want interactive mode to plot live dataĭef makeFig(): #Create a function that makes our desired plot Import matplotlib.pyplot as plt #import matplotlib libraryĪrduinoData = serial.Serial('COM4', 115200)
But you need to make some modifications to it though. The link below is a good place for you to get going. Set(plotGraph3,'XData',time,'YData',R,'color','b') ĭrawnow %force matlab to updata plot instantaneously
%set() is used to set graphic object properties
Then you have to set up the plot and force matlab to update the plot in real time. YPR = Yaw, Pitch, Roll data = fscanf(s) %Read Data from Serial Then, from Matlab, you need to write a script to be able to read this string and identify any floating-point value. In my case, I'm working with IMU and my data format is as an example: #YPR = 2.34, 13.23, -2.20 Then take note of the format of the data coming out of your Accelerometer. You need to establish communication between those two first. First, you need to read about serial communication between matlab and arduino.