MATLAB: Arduino i2c communication

arduino i2c comunocation and readvolatge from i2c device master or slave

I am a beginner, and have difficulty understanding the programming language on Arduino i2c communication, and I have tried it but to no avail, I beg for your help, how to display the voltage data readings on each of the Arduino in matlab?
Thank you,
a = arduino("COM15","Uno","Libraries","I2C") %Create an arduino object with I2C library.
dev = i2cdev(arduinoObj,'0x02'); %Create a device object.
L00 = readVoltage(a,'A0'); % readvoltage at master
R00 = readVoltage(a,'A0'); % readvoltage at slave

Best Answer

Notice that you are only communicating to one arduino, and you connect to only one i2c bus, and that you read from the same A0 register on that one bus.
Your diagram appears to show the kind of configuration you would use for setting a voltage on one arduino and reading it on a different arduino... except that you do not show any i2c devices.
Ah...
dev = i2cdev(arduinoObj,'0x02'); %Create a device object.
The i2cdev() call is only for Raspberry Pi hardware. You would need https://www.mathworks.com/help/supportpkg/arduinoio/i2c-devices.html
dev = device(arduinobj, 'I2CAddress', '0x20');
Then look at
L00 = readVoltage(a,'A0'); % readvoltage at master
Notice this was a call to read from an analog voltage pin connected directly to the Arduino, not from the I2C device. In particular it asks to read from the A0 pin, which is the one that on your left device is connected to the purple (center) wire of your left potentometer, which is the voltage reading.
On the right hand pot, the voltage reading is connected to A0 of the second arduino.
You can skip working with I2C at all (at least for the purpose of the readings) if you connect the second arduino to the host and use a second arduino object.
You can also skip working with I2C at all if you configure the second arduino to read from its A0 and write the values to either A5 or A6, and have the first arduino read from that pin with a readVoltage .
It is not obvious to me that working with I2C is adding anything of value to your situation.