Try
void setup()
{
// Start serial at 9600 baud
Serial.begin(9600);
}
void loop()
{
// Read the input on analog pin 11 and 12:
int sensorValue = analogRead(A11);
int sensorValue2 = analogRead(A12);
Serial.print(sensorValue);
Serial.print(",");
Serial.println(sensorValue2);
/*
And you will send strings like:
10,20\n
11,15\n
100,255\n
where \n is line feed and I removed the text strings, which are not necessary IMHO.
.and so on .....
The MATLAB receiver code is yours, see below ..
*/
}
I have no clue how it the code to receive data from a serial line looks like in Matlab. But this is a fragment I'm using Processing.
// Read serial data
while (myPort.available() > 0) { // New data?
char ch = myPort.readChar();
if (ch >= '0' && ch <= '9') {
value[arrayIndex] = (value[arrayIndex] * 10 + (ch - '0'));
} else if (ch == ',') {
arrayIndex++;
kommaZahl++;
} else if ( ch == '\n') {
// Print results when in debugging mode
if (debug) {
println(value[0]);
println(value[1]);
}
And you can easily check the results using the serial console in ARDUINO.
You may find some code for Matlab here How To Send Data From The Arduino To MATLAB Communication