Arduino Due serial communication with matlab


I’m trying to read some sensor data from my arduino due through serial communication into matlab. This works sometimes, other times I read strange signs.
I’m not using the library from arduino in matlab because I made some changes in the register of the mcu. The reason here is that I want a quicker ADC. Now I’m sure this isn’t the problem. I tried allready without changing the register, but is was still the same.

This is my arduino code:

void setup() {

   ADC->ADC_MR |= 0x80;  //set free running mode on ADC
   ADC->ADC_CHER = 0x80; //enable ADC on pin A0

void loop() 

and this is my matlab code :

close all
clear all

samples = 300;

comPort = 'COM1';

if ~isempty(instrfind)

s = serial('COM1', 'BaudRate',9600, 'DataBits' , 8, 'StopBits', 1);
%line1 = line(nan, nan, 'color', 'red');
i = 1;
while (i<samples)
       value = fscanf(s,'%d');
       x(i) = value;
       plot(x, 'r')
       grid on;
       hold on;
       i = i+1;


Does anybody have an idea why I read sometimes those strange signs?

Does anybody have an idea why I read sometimes those strange signs?

Which end of the serial pipeline has the problem? Open the Serial Monitor application instead of Matlab. If the Serial Monitor application displays the data correctly, the problem is not the Arduino.

What are the strange signs?

(Try bumping your serial speed to 115200 - Writing at 9600 is pretty slow)