Data input from a com port in matlab

There is Arduino, which is in the com port sends data from the sensor every 100 MS. Want to smooth noise in matlab and plot graphs. In array to record the data stream? Or, better yet, maybe you can do it in realtime?
How to open a port know get single value by using fgets(s). In an array multiple values to send not think. Please help.

October 3rd 19 at 02:06
1 answer
October 3rd 19 at 02:08
Something like this:
NB.BaudRate = BaudRate;
NB.IOFileName = IOFileName;
 s = serial(NB.IOFileName);
system(sprintf('stty -F %s %d', NB.IOFileName, NB.BaudRate));
NB.IOid = fopen(NB.IOFileName, 'w+');

k = 0;
 b = fread(NB.IOid, 1, 'uint8'); % a Single byte from the port
 k = k + 1;
 byte_array(k) = b;

But in this example, byte_array dynamically stretched. To better digest the data on the fly instead of writing them into an array.

Find more questions by tags ArraysMATLABSerial port