please use the CTRL-T in the IDE to auto indent the code to make it more readable
and please, use the # button to get code tags around it.
Why are you communicating at 9600 baud? Arduino can do 115200 (12x as fast!) keeping the buffers quite empty.
here a variation of your code that sends the value of analogRead /4 to mathlab so mathlab can check what the value was.
It uses a higher baudrate.
void setup()
{
Serial.begin(115200);
}
void loop()
{
while(Serial.available() == 0); // wait for mathlab
int num = Serial.read();
if (num == '1') // sending '1' from matlab to initiate reception
{
int value = analogRead(A0)/4;
Serial.write(value);
delay(5);
}
}