converting the data received from matlab GUI to binary in arduino,

Hello,
my question is about how to convert the data received from matlab GUI to binary in arduino and then classify it into bits
for example i refer the first 3 bits to (x parameter) for example number 3
and my second three bits to(y parameter )for example number 4
i want the arduino to convert them as

010 100

how can i do this ??

what communications technology are you using to transmit the data from matlab to an arduino, e.g. RS232 serial, WiFi, ?
is the data transfer as binary in 6 bits or a sequence of characters "010100" ?
either wya you should be able to implement a program in C/C++ on the arduino to convert the binary patterns to an integers for processing

horace:
what communications technology are you using to transmit the data from matlab to an arduino, e.g. RS232 serial, WiFi, ?
is the data transfer as binary in 6 bits or a sequence of characters "010100" ?
either wya you should be able to implement a program in C/C++ on the arduino to convert the binary patterns to an integers for processing

an interface package installed in matlab and a library too are used to communicate both together
the data will be transfered to arduino as interger numbers , what i need is that the arduino will convert it to binary

(deleted)

you receive six integer numbers 0 1 0 1 0 0 and you wish to form a single binary value ?
something along the lines of

void setup() {
   Serial.begin(9600);
   int data[]={0,1,0,1,0,0};  // integer numbers
   byte bin=0;
   for  (int i=0;i<6;i++)
     bin = (bin << 1) | data[i];
   Serial.println(bin, BIN);  // binary value
}

void loop(){}

a run gives

10100

no, i want each received number to be converted to a binary separated from the others
i mean when i receive 1 it should convert it to 001
then 2 be converted to 010 and so on
each is on different and separated bits

horace:
you receive six integer numbers 0 1 0 1 0 0 and you wish to form a single binary value ?
something along the lines of

void setup() {

Serial.begin(9600);
  int data[]={0,1,0,1,0,0};  // integer numbers
  byte bin=0;
  for  (int i=0;i<6;i++)
    bin = (bin << 1) | data[i];
  Serial.println(bin, BIN);  // binary value
}

void loop(){}



a run gives


10100

no, i want each received number to be converted to a binary separated from the others
i mean when i receive 1 it should convert it to 001
then 2 be converted to 010 and so on
each is on different and separated bits

when you receive 2 do you wish to print is as binary or convert it into a string "010" or three integers 0 1 0

@TasneemSaad, please post your Arduino program so we can see what you can see.

Also, please provide a few examples of the messages that are sent by Matlab.

Without the facts everyone (including you) is just wasting time.

...R

horace:
when you receive 2 do you wish to print is as binary or convert it into a string "010" or three integers 0 1 0

convert it into a string

Robin2:
@TasneemSaad, please post your Arduino program so we can see what you can see.

Also, please provide a few examples of the messages that are sent by Matlab.

Without the facts everyone (including you) is just wasting time.

...R

sorry but i haven't started yet
i need to know the answer of my question so i can start coding

assuming you require a null terminated char[4] array try this

void setup() {
   Serial.begin(9600);
   int data[]={1,2,3,4,5,6};  // integer numbers
   for  (int i=0;i<6;i++)
   {
       char bin[4]={0};
       // convert three bits
       for (int j=2;j>=0;j--)
       {
          bin[j]=(data[i] & 1) + '0';
          data[i]>>= 1;
       }
       Serial.println(bin);  // binary value
  }
}

void loop(){}

when run gives

001
010
011
100
101
110

TasneemSaad:
sorry but i haven't started yet
i need to know the answer of my question so i can start coding

Do you mean that you have no Matlab program as well as no Arduino program?

If you do have a Matlab program please, as requested, provide some samples of its output. You can probably capture it and display it using the second example in Serial Input Basics. That will also be a useful start for your programming,

If you don't have a Matlab program then give some examples of the data that you would like the Matlab program to send.

...R