arduino-matlab-interfacing

Hello!
recently i decided to make an arduino inspired rubik’s cube solving machine,but i encountered a problem transferring data from matlab to my arduino ,heres the part of the matlab code that prints out in a temporary file a string that holds simply letters reffering to the sequential moves that would solve the cube(ex:FDBF’LU…etc):

fprintf(fid,'\n\nSolution (%d moves):\n',numel(solution));
   count = 0;

   *a1=serial('COM6','BaudRate',115200);*

   *fopen(a1);*

   for i=1:numel(solution)-1
       fprintf(fid,'%s,',solution{i});

       *fprintf(a1,'%s,',solution{i});*

       count = count + numel(solution{i})+1;
       if count>72
           count = 0;
           fprintf(fid,'\n');
       end
   end
   fprintf(fid,'%s',solution{end});
   fclose(fid);

   *fclose(a1);*

   open(fname)

the lines between the ** are the ones i added for serial communication between matlab nad arduino.
i simply copied the same process used to print in the temporary file,but for the arduino-a1.

and heres the arduino code:

char matlabData;
char v[100];
int i=0;
void setup() 
{
 Serial.begin(115200);
 pinMode(13,OUTPUT);
}

void loop() 
{
  if (Serial.available()>0){
     matlabData=Serial.read();
     v[i]=matlabData;
     if(v[i] == 'F'){
     digitalWrite(13,HIGH);
}
     i++;
 }
}

the arduino code is just to test if im recieving anything,if yes the led(pin 13) turns on.
I simply scramble the cube using F’(anticlockwise) so the solution would be F(clockwise).
can anyone help? i gave up!
Thanks in advance!

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

can anyone help

You did not post your code correctly, so I am certain that your Arduino code does not look like that.

You have not described what the Arduino code actually does,

So, no.

One thing you might need to be aware of is that opening the serial port resets the Arduino, and you are jamming data at it before it is ready. By the time it is ready, you've closed the serial port.

We don't do Matlab here, so it can be Greek as far as we know.

There are plenty of tutorials on how to program the Arduino to read from the serial port.

ieee488:
We don't do Matlab here, so it can be Greek as far as we know.

Given your inappropriate use of the personal pronoun "we" I assume your first language is not English. The correct word for that sentence is "I".

shadihalabi95:
can anyone help?

PaulS:
So, no.

He lied...

PaulS:
One thing you might need to be aware of is that opening the serial port resets the Arduino, and you are jamming data at it before it is ready. By the time it is ready, you've closed the serial port.

That is very likely the problem. Try disabling auto-reset. Or add a two second delay to the MATLAB code.

You could also use the arduino add in for Matlab, as far as I know it allows you to connect to and run an arduino from Matlab.