my arduino code does not read any characters inputted from matlab

I'm doing a serial communication from matlab to arduino. And my codes are written below. I just need suggestions or some advices because I'm not sure if my arduino is really reading the exact string that I'm inputting in matlab. However when I run the the matlab itself, fscan is reading and displaying the right set of characters. Please, are my codes right? I'm really confused.

====MATLAB CODE======



s = serial('COM7', 'BaudRate', 38400);



text=input('enter: ','s');

fprintf(s, text,'sync');




delete(instrfindall) ====ARDUINO CODE=====

String inData; // Where to store string char received; // Where to store the character read // Index into array; where to store the character

void setup(){ Serial.begin(38400); }

void loop() { while(Serial.available() > 0) // Do not execute if one less than the size of the array { char received =; // Read a character inData += received; if(received == '\n'); { Serial.print(inData); inData=""; } }