以下是我目前的MATLAB代码。代码正常运行,但我想知道是否有一种方法可以在更新时显示循环外的数据。 ThingSpeak是我正在使用的一种当前方法,但我也想在MATLAB中看到它。
a = Bluetooth('HC-05',1);
a.ReadAsyncMode = 'continuous';
fopen(a);
heartRateVar=0;
temperatureVar=0;
accVar=0;
while (a.Status == 'open')
rawData = fscanf(a,'%s');
idx = strfind(rawData,'_');
match = strtrim(rawData(1:idx-1));
test = strncmpi(match,'Celsius',2);
if(test==1)
temperatureVar=match;
elseif(test==0)
if(strncmpi(match,'BPM',2)==1)
heartRateVar=match;
end
end
%create arbitrary time stamps of same size as data points to send data
to thingspeak
stamps = [datetime('now')-minutes(length(match)-1):minutes(1):datetime('now')]';
%send data accompanied by timestamps to thingspeak
thingSpeakWrite(501358,{heartRateVar,temperatureVar,accVar},'WriteKey','JLS6DXUINWFGI6QD');
if(a.Status ~= 'open')
break;
end
end
谢谢!
答案 0 :(得分:0)
您可以通过在变量行上设置断点并运行代码来使用调试模式,也可以在屏幕上打印