Matlab-arduino the data is not showing

Hello,

my name is Nabila, and i'm new here and english isn't my mother-tongue language, i'm sorry if there's any mistake in the way i explain my problem.

My project is to read temperature and command it from matlab to arduino and then plot the data into graphic. The background is showing at the moment i call the arduino, unfortunately the data isn't.

Here is my arduino code :

int mode=-1;

float tempC;
int tempPin = 0;

void setup()
{ Serial.begin(9600);
  //check serial communication-acknowledgment routine
  Serial.println('a');
  char a = 'b';
  while(a !='a')
  {//wait specific character from PC
    a=Serial.read();
   }
  
}

void loop()
{
  if (Serial.available()>0) //check is any data has been sent by PC
  { mode=Serial.read(); //read request for data
    Serial.println(tempC);
    switch(mode)    //used to set different modes for various operation
    {
      case'T':  //T is used to read temperature value
      getTempCent();//get the value of temperature
      //Serial.println(tempC);
      break;
    }
  }
}

void getTempCent()
{ 
  tempC = analogRead(tempPin);
  tempC = tempC * 0.48828125;
  
  delay(1000);
}

and here is the part that cannot show up on the matlab:

%5.Runs a loop that continually read temperature
    mode='T';
    while(get(button,'UserData'))
        tc=ReadTemp(arduino,s,mode);
        tcdata=[tcdata(2:end),tc];
        set(s,'Zdata',[tcdata;zeroIndex],'Cdata',[tcdata;tcdata])
        drawnow;
    end

when the graph (without the data appears from arduino) is come out, there's no error in any line.
If there's any possible answer you know, please kindly tell me . And if you need more information about the coding , i'd like to share it with you.

thank you

Arduino, C#, and Serial Interface - CodeProject has Arduino code that will respond to serial commands from C# program.

It worked for me.

It should be fairly simple to modify the C# to Matlab code.