read and write error in matlab
You need to segment that problem a little.

Step 1) Check your uC Code


Attach a terminal tool (such as PuTTY) instead of Matlab to your uC; also show us your physical setup. You are aware that you MUST NOT directly connect the uC to your PC, right (there needs to be some level translating device in between)? Use your settings for setting up PuTTY (probably 9600 baud, 8 data, 1 stop bits, no parity, no flow control)
Use PuTTY to send characters and check what the uC is actually doing (you can actually debug the uC, correct?)
Make a very simply program that just does the following


Example code:

char c;
UART1_Init(9600);
  while(1){
    if (UART1_Data_Ready()){
      c = UART1_Read();
      UART1_Write(c);
      UART1_Write(c);
      UART1_Write(c);
    }
  }  


I should echo each character you send three times back (why three? So we know it's not the echo of your terminal program). You need to get this to work, otherwise there is no use in using Matlab, it just complicates your problem.

If you want it to be even simpler, try the following

char c = 'z';
UART1_Init(9600);
while(1){
  UART1_Write(c);
}


This will just send the character 'z' over and over again, you should see a long line of 'z's in your terminal program.

Step 2) Correct the Matlab Code

Once you have the setup from above running and working, you should now work on your matlab code. Chances are high it will work right away, but for that you might need someone else.

Debugging Info)
If you encounter strange characters there are many potential issues. Just to name a few


Wrong Baudrate or generally wrong settings for your serial interface
Microcontroller was configured wrong for that baudrate (do you need to setup any clocks first?)