title: Plotting all the axes of Accelerometer in MATLAB using XBee+Arduino
body: <p>I am trying to plot the real time graph of all the axes of the accelerometer wirelessly by XBee through MATLAB.<br>
  I have achieved the following until now:  </p>
  
  <ul>
  <li>On the transmitter side, I have an Arduino connected with an Xbee shield. I am using a Series 2 Xbees for this purpose.  </li>
  <li>I have an ADXL335 breakout board accelerometer hooked in to the analog pins Arduino+Shield combo and also the XBee (Co-Ordinator API) on the shield.  </li>
  <li>On the receiver side, I have an XBee  (Router AT) connected to a computer which will record the output and plot it in MATLAB.  </li>
  </ul>
  
  <p>I also want to mention that I am using the Arduino library for MATLAB for the Arduino code.  </p>
  
  <p>Now, when I wire up the Arduino (i.e. I don't use the Xbee) then I get a perfect output of all the axis of the accelerometer.<br>
  But when I hook in the Xbee and try to communicate with the arduino I get nothing. E.g. when use the Xbee the command to plot the graph is:  </p>
  
  <pre><code>a = arduino(COM X);  
  </code></pre>
  
  <p>where <code>X</code> is the COM port where the Arduino is connected.  </p>
  
  <p>How should I change the command when I connect my Xbee? (Recalling again that my Arduino and accelerometer are not connected to the computer but my receiver side Xbee is.)</p>
  
  <p>Here is my MATLAB code:</p>
  
  <pre><code>a.pinMode(15,'input'); 
  a.pinMode(16,'input'); 
  a.pinMode(17,'input'); 
  a.pinMode(18,'output'); 
  a.pinMode(19,'output'); 
  a.digitalWrite(18,0); 
  a.digitalWrite(19,1); 
  xval = zeros(); 
  yval = zeros();
  zval = zeros();
  
  xval(1) = a.analogRead(3); 
  yval(1) = a.analogRead(2); 
  zval(1) = a.analogRead(2);
  
  pause(.001); 
  
  for i = 2:1000
  
      xval(i) = a.analogRead(3);
      yval(i) = a.analogRead(2);
      zval(i) = a.analogRead(2);
  
  
      xmod = (xval-496)/300;
      ymod = (yval-511)/300;
      zmod = (zval-508)/300;
  
      subplot( 3,1,1)
      plot(xmod, 'r');
      axis([1 1000 -0.5 0.5]);
      title( 'x' );
  
      subplot( 3,1,2)
      plot(ymod, 'r');
      axis([1 1000 -0.5 0.5]);
      title( 'y' );
  
      subplot( 3,1,3)
      plot(zmod, 'r');
      axis([1 1000 -0.5 0.5]);
      title( 'z' );
  
      pause(0.001);
  
  end
  </code></pre>