Weird problem

Hi guys, I got a weir problem about serial port communication(to Arduino) on mac when I was executing my code. Every time if I execute my code step by step, the read() and write() to the serial port would work normal but once I exit the debugger and run the code, it seems that although there is return value to write() but the board doesn't respond at all. The same thing happened to my mac Matlab. If I type fprintf() in command line and use out = fscanf() to read the bytes sent back from arduino in response of fprintf(), it would always give me correct answer. However when I run the same code in a blank m-file, there is nothing written back by the arduino board. HELP!!!!

Are you waiting in your code for data to be available before you read it? Executing the code slowly would ensure you always had data.

If not post the code (use the has button in the reply box)