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======

delete(instrfindall)

text=1;

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

fopen(s);

pause(0.1)

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

fprintf(s, text,'sync');

pause(0.1);

fscanf(s)

pause(0.1)

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 = Serial.read(); // Read a character inData += received; if(received == '\n'); { Serial.print(inData); inData=""; } }

}