user57669: ****i am using ATmega32 to send float and want to receive it on matlab,i send 4.85 from ATmega32 but on matlab i receive 4.260233679216239e-31...can any one help me..thanks in advance**
**
    //Atmel studio code++++code for sending float from Atmega32
    union abc{ float fo; unsigned long lo; };
 union abc data; 
int main(void)
 { usart_init();
 data.fo=4.85;
 while(1) {
for(int i=0; i<=24; i+=8) 
{
    uart_send(data.lo>>i); }}}

 //Matlab code for receiving float 
s=serial('COM1','BaudRate',9600); 
fopen(s); 
out=fread(s,1,'single'); 
 fclose(s);


user57669: i found the solution for this problem, i set a header before sending the data from ATmega32,and on Matlab i check the frame ,if it received correctly,i receive the data
//ATmega32 code
    float x =215.5;
    unsigned char *ptrx;
    int main(void)
    {   usart_init();
        //data.fo=12.85;


        ptrx=( unsigned char *) &x;
          while(1)
       {
        uart_send(0xAA);//equals to 170 
        for(int i=0;i<4;i++){
        uart_send(*(ptrx+i));}

        x++;}}
    //on Matlab
    s=serial('COM1','BaudRate',9600);
    fopen(s);
     i=1;
    while i<1000
        header =fread(s,1,'uint8');

        if header==170//equal to 0xAA

     out=fread(s,1,'float');
    data(i)=out;

     i=i+1;
        end
     end
    fclose(s);


57669: <p>****i am using ATmega32 to send float and want to receive it on matlab,i send 4.85 from ATmega32 but on matlab i receive 4.260233679216239e-31...can any one help me..thanks in advance**
**</p>

<pre><code>    //Atmel studio code++++code for sending float from Atmega32
    union abc{ float fo; unsigned long lo; };
 union abc data; 
int main(void)
 { usart_init();
 data.fo=4.85;
 while(1) {
for(int i=0; i&lt;=24; i+=8) 
{
    uart_send(data.lo&gt;&gt;i); }}}

 //Matlab code for receiving float 
s=serial('COM1','BaudRate',9600); 
fopen(s); 
out=fread(s,1,'single'); 
 fclose(s);
</code></pre>
 57669: <p>i found the solution for this problem, i set a header before sending the data from ATmega32,and on Matlab i check the frame ,if it received correctly,i receive the data</p>

<pre><code>//ATmega32 code
    float x =215.5;
    unsigned char *ptrx;
    int main(void)
    {   usart_init();
        //data.fo=12.85;


        ptrx=( unsigned char *) &amp;x;
          while(1)
       {
        uart_send(0xAA);//equals to 170 
        for(int i=0;i&lt;4;i++){
        uart_send(*(ptrx+i));}

        x++;}}
    //on Matlab
    s=serial('COM1','BaudRate',9600);
    fopen(s);
     i=1;
    while i&lt;1000
        header =fread(s,1,'uint8');

        if header==170//equal to 0xAA

     out=fread(s,1,'float');
    data(i)=out;

     i=i+1;
        end
     end
    fclose(s);
</code></pre>
