
Once you read a byte of data, it is no longer in the buffer.

If your program reads a value from the buffer, it starts at the top of the list (oldest data). As new data values come in they get added to the bottom of the list (most recent data). One writes data into it and other reads it, may be with different speeds. Then the data is stored to a list which we call a buffer. Say a sensor is streaming back data to your program, more frequently than your program reads it. There exists a buffer between the two events of sending and reading the data. It is most important to understand the nature of buffer to avoid errors later while writing codes. MATLAB can read/send the data from/to the serial port of the computer and process it. One side sets the pin and the other reads it. Just like we turn an LED on and off, we can also send data. Information is passed back & forth between the computer and Arduino by, essentially, setting a pin high or low. Serial communication is when we transfer data one bit at a time, one right after the other. You should be familiar with MATLAB structures, MATLAB objects etc. Serial Communication between Arduino and MATLAB

Serial Communication between Arduino and MATLAB ByAman Mangal IIT Bombay
