I figureed out the solution for this problem. The following steps seem to be helpful:
1. In Ubuntu PC hosts file (/etc/hosts), add the hostnames and the IP addresses of both Ubuntu PC and Windows PC
2. In Windows PC host file (/windows/system32/driver/etc/host), do the same thing as in previous step
3. Turn off all the firewalls on Window PC and Ubuntu PC (if there is any)
4. Reboot both machines to make the new host files effective
5. Set the following environment variables on Ubuntu PC
sudo gedit ~/.bashrc
Add the following lines in .bashrc file, save and then restart terminal
export ROS_MASTER_URI=http://Ubuntu_PC_IP:11311
export ROS_IP=Ubuntu_PC_IP
6. On Windows MATLAB, set the environment variables for ROS:
setenv('ROS_MASTER_URI','http://Ubuntu_PC_IP:11311')
setenv('ROS_IP','Windows_PC_IP')
rosinit
Then it should work. I did almost everything except Step 2, which caused the above problem. I hope this would help someone who has the similar problem.