HC-06 sending data to MATLAB

Hello all,

I am wanting to just send data from an Arduino Due to a MATLAB array via an HC-06 Bluetooth Module. The bluetooth is definitely being picked up by MATLAB, but I cannot seem to just send a value from a counting sketch I edited:

int a1=0;
    
    void setup()
    {
    Serial.begin(9600);
    }
     
void loop()
{
        
   if (Serial.available() >0) {

    /* whatever is available from the serial is read here    */
         
        
        Serial.println(a1);
         
  a1++;
  delay(1000);
         }
}

This code was derived from this webpage:

My MATLAB code is listed here:

clear;
b=Bluetooth('HC-06',1);
fopen(b);

q = zeros (1,1024)

  for i = 1:1024
    q(i) =fscanf(b,'%d');
  end

I receive the error :
"In an assignment A(I) = B, the number of elements in B and
I must be the same.

Error in Bluetoothtest ( line 8 )
q(i) =fscanf(b,'%d');"

I don't really know if i need to write exactly where b is, or if i need to scan from another place within b. Thanks so much for any help or direction to a source that could help.

-Caleb

Maybe you can try

q(i) =fscanf(b,'%d', 1); // add SIZEA argument to return a single reading

GREAT SCOTT!!! IT WORKED!!!

Thanks so much. You have saved my senior design from my ignorance of matlab. May the force be with you.