MATLAB: Getting characteristic of a BLE fails with a “Device profile has changed”

MATLAB

When I try to run "characteristic" on a "ble" (Bluetooth Low Energy) object, it fails with an error. This only occurs if there is some pause between creating a "ble" object and checking its characteristics. Without the pause, it works fine, however.
Why does this error occur? Below is my reproduction code:
a = blelist;
b = ble(a{1,3});
% Pausing causes the following error
% Device profile has changed. Clear existing ble object with address 3C2A6CF3F3A8 and recreate it.
pause(0.15)
c = characteristic(b, "Battery Service", "Battery Level")

Best Answer

This is a known issue which was fixed in R2019b Update 3. Please see the Bug Report here:
The preferred solution is to update your MATLAB release.
Alternatively:
To successfully create a characteristic object, you must pair your Bluetooth Low Energy device on Windows before using "ble" to connect to it in MATLAB. You can pair to a device in Windows Settings > Devices > Add Bluetooth or other device.