Problem of Arduino Uno Send Data to MATLAB

Thread Starter

lauboonchong

Joined Feb 23, 2022
2
Hi, I am sending data from Arduino Uno to MATLAB. Below is my Arduino and MATLAB code.

Arduino Code:
const float sensorVoltage=A0;
void setup() {
Serial.begin(9600);
}
void loop() {
float inputVoltage2=analogRead(sensorVoltage);
float voltage2=5*inputVoltage2/1024;
Serial.println(voltage2);
}

MATLAB code:
delete(instrfind({'Port'},{'COM7'}));
s = serial('COM7', 'BaudRate', 9600);
fopen(s);
a=fgetl(s);
disp(a)
fclose(s);

However, the value received has a weird symbol in front of it as shown below:
1707701326418.png

Anyone can help me solve this problem? Thank you very much
 
Top