ARDUINO + MATLAB Real time graph *help asap please

I am working on a controls project. mech engr dont know much about ece
i have an IR emitter and detector that detects how fast the radiometer is spinning using the arduino uno
the code is here

int ledPin = 13;
int statusPin = 12;

volatile float time = 0;
volatile float time_last = 0;
volatile int rpm_array[5] = {0,0,0,0,0};
volatile int stat;

void fan_interrupt() {
  time = (micros()-time_last);
  time_last = micros();
  
  if(stat == LOW) {
    stat = HIGH;
  }
    else {
      stat = LOW;
  }
  digitalWrite(statusPin, stat);
  
}

void setup() {
  Serial.begin(9600);
  
  attachInterrupt(0, fan_interrupt, FALLING);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
  pinMode(statusPin, OUTPUT);
  
}

void loop() {
  int rpm = 0;
  
  while(1) {
    delay(1000);
    
    if(time>0) {
      rpm_array[0] = rpm_array[1];
      rpm_array[1] = rpm_array[2];
      rpm_array[2] = rpm_array[3];
      rpm_array[3] = rpm_array[4];
      rpm_array[4] = 60*(1000000/(time*4));
      
      rpm = (rpm_array[0] + rpm_array[1] + rpm_array[2] + rpm_array[3] + rpm_array[4])/5;
    
    Serial.println(rpm,DEC);
    
    }
  }
}

i need help in creating the real time plot on matlab
the graph should show rpm vs time

a=arduino('com4');
Attempting connection .............
Basic I/O Script detected !
Arduino successfully connected !

i got the uno to connect to matlab
just need help on the code
can anyone help me please asap

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

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

Please do not cross-post.

just need help on the code

Did you get help writing that Arduino code on the MatLab forum?

1000000 ==> 1000000L to explicitely make it long, for the rest it should work (you do some average rounds per minute ?)