Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 在循环外部显示保存的数据_Matlab - Fatal编程技术网

Matlab 在循环外部显示保存的数据

Matlab 在循环外部显示保存的数据,matlab,Matlab,下面是我当前的MATLAB代码。代码正常运行,但我想知道是否有一种方法可以在循环更新时显示循环外部的数据。ThingSpeak是我目前使用的一种方法,但我也想在MATLAB中看到它 a = Bluetooth('HC-05',1); a.ReadAsyncMode = 'continuous'; fopen(a); heartRateVar=0; temperatureVar=0; accVar=0; while (a.Status == 'open') rawData = f

下面是我当前的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

谢谢

您可以通过在变量行上设置断点来使用调试模式并运行代码,也可以在屏幕上打印代码