Exporting data as .txt file from 8051 to PC
A better way to do this would be to use an RS232 peripheral to interface with the PC and let the PC record the data as a .txt file. Why? because an 8051 doesn't have that many resources to implement a filestream (it could be done) but it would be much better to use RS232 if you have the option.  

Then use realterm to log it as a .txt file and import it into matlab