Arduino and MATLAB for a stepper motor

Hi,

I am currently using Arduino Mega 2560 to control a stepper motor. I would like to use MATLAB to send two commands to Arduino to set both the motor speed an rotation direction. In the coding below, I managed to control the motor speed but cannot control the rotation direction. Can anyone help me to add a code to be able to use MATLAB to control the rotation direction when I need to reverse the rotation?

Arduino code:

#include <Stepper.h>

const int STEPS_PER_REV=200;
Int DIRECTION=1;
int SPEED_CONTROL=0;                       
Stepper motor(STEPS_PER_REV, 8, 9, 10, 11);
 
void setup() 
{
  Serial.begin(115200);                       
 }
 
void loop() 
{
  if (Serial.available()>0)
  {
   SPEED_CONTROL=Serial.read();
   motor.setSpeed(SPEED_CONTROL);         
  }
 motor.step(STEPS_PER_REV*DIRECTION);            
}

MATLAB Code:

delete(instrfindall);
SPEED_CONTROL=100;
DIRECTION=-1;
%DIRECTION=1;
a=serial('COM10','BaudRate',115200);
fopen(a);
pause(1);
fprintf(a,'%s',SPEED_CONTROL);
fclose(a)

The serial input basics tutorial may give you some ideas.

Thank you. It works now.