title: How to read serial data correctly through Matlab
body: <p>I am using Matlab to read data from a serial port coming through a microprocessor. The data is in hexadecimal format with each sample of 4 bytes(32 bits). When I read this data, I get some random sequence of numbers which don't match the transmitted data. Below is my code</p>
  
  <pre><code>s = serial('COM16'); %assigns the object s to serial port
  
  set(s, 'InputBufferSize', 128); %number of bytes in inout buffer
  set(s, 'FlowControl', 'none');
  set(s, 'BaudRate', 921600);
  set(s, 'Parity', 'none');
  set(s, 'DataBits', 8);
  set(s, 'StopBit', 1);
  set(s, 'Timeout',100);
  %clc;
  
  disp(get(s,'Name'));
  prop(1)=(get(s,'BaudRate'));
  prop(2)=(get(s,'DataBits'));
  prop(3)=(get(s, 'StopBit'));
  prop(4)=(get(s, 'InputBufferSize'));
  
  disp([num2str(prop)]);
  
  fopen(s);           %opens the serial port
  
  data = fscanf(s);
  
  fclose(s); %close the serial port
  </code></pre>
  
  <p>Please tell me what I am doing wrong do that I can get the correct heart sound.
  thanks</p>