MyArduino=arduino();    %PCと接続されているArduinoとMatlabの通信開始
bus=0;  %温度センサーが接続されているArduinoのI2C通信のバス指定
Tsensor = device(MyArduino,'I2CAddress',char(scanI2CBus(MyArduino,bus)),'bus',bus); %温度センサーとの接続

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

AMBIENT_TEMP = 0x05;    %現在温度レジスタ

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

write(Tsensor,AMBIENT_TEMP);    %現在温度レジスタを指定
data=uint8(read(Tsensor,2,'uint8'));    %8bit×2=16bitのデータを取得

Temperature=double(bitand(data(1),0x0F))*16+double(data(2))/16; %温度[℃]に変換
