实验数据处理

来源

加热冷却温度实验,相同实验参数可能有一次或多次重复实验,一次实验中也可能有多次。如何分别每一次周期,并把每个周期的数据都分析出来,成为一个问题。
请添加图片描述

解决思想

  1. 想根据冷却后的平台划分不同周期,但是由于冷却介质温度不同,平台数值也不同,并且部分时间冷却为到出现平台就进行了加热,只是达到 threshold就加热。
  2. 根据 相邻 数据点的 difference 分别,但是当加热功率小 冷却速度慢,采样频率高(200 Hz)相邻点的差值基本没有太大变化。
  3. 最终采取 第 N 个点 和 N+ Num 个点之间的斜率作为参考斜率,区分出加热过程冷却过程 和稳态过程, 并结合 peek 点 进一步判断斜率是不是在加热阶段和冷却阶段。 Num20, 采样频率200Hz, 实际只有0.1s。

实现过程

子文件夹及文件处理

由于实验数据在 ‘.mat’ 文件中,改文件在root目录下的二级目录中。

划分实验


load(TemperatureMatFile, 'temperature_series');   	%  加载数据
Time = temperature_series(1,:);
T1   = temperature_series(3,:);

% TF = ischange(T1, 'mean', 'Threshold',10);
% pts=findchangepts(T1,'Statistic','linear','MinThreshold',30);

% T1_med = medfilt1(T1,7);						% 数据平滑
T1_med = transpose( smooth(T1,17) );
NumThreshold = 20;          % compare the N+NumThreshold with N for slope
T1_tmp = T1_med(NumThreshold+1 :end ) - T1_med(1:end-NumThreshold);
T1_slope = T1_tmp / (0.005*NumThreshold); % 0.005 for 200 Hz sampling rate
% T1_slope_smooth = medfilt1(T1_slope, 5);
T1_slope_smooth = transpose( smooth(T1_slope, 17) );



[pks,locs] = findpeaks(T1, 'MinPeakDistance', 1000, 'MinPeakHeight', 60) ; 		% 找到peek

ind_1 = 1;
ind_2 = ind_1;
if isempty(locs)			% .mat 文件没有存储加热到60度的话直接丢弃,返回空
    ExpResult = struct.empty;
    return;
end
for i = 1:length(locs)
    ind_1 = ind_2;				% 一个文件中有多次实验,前一个实验冷却结束时间是后一次加热备选区间
    ind_2 = locs(i);

    % heating section
    index = false(1,(length(T1)-NumThreshold));
    index(ind_1:ind_2) = true;												% 本次分析所提取的数据,针对一个文件中有多次实验
    % heating start below 25 degC are not guaranteed
    heat_start = find(T1(index)<25, 1, 'last')+ ind_1;         
    if isempty(heat_start)						 % 由于加热不一定每次都是从 25度开始加热,
        heat_start = find(T1_slope_smooth(index)>2, 1, 'first') + ind_1;  %这个 大于2  是绘制了 斜率曲线后 决定的,需要尝试
    end
    heat_stop    = find(T1(index)<60, 1, 'last') + ind_1;
    
    heat_time(i)    = Time(heat_stop) - Time(heat_start);
    heat_T(i,1)  = T1(heat_start);
    heat_T(i,2)  = T1(heat_stop);
    heat_ind(i,1)= heat_start;
    heat_ind(i,2)= heat_stop;
    
    
    % cooling section
    index = false(1,(length(T1)-NumThreshold));
    index(ind_2:length(T1)-NumThreshold) = true;
    cool_start = find(T1(index)<60, 1, 'first') +ind_2;
    
    index(ind_2:cool_start) = false;        % cooling stop point larger than cooling start
    % cooling to 25 degC are not guaranteed
    cool_stop  = find(T1(index)<25, 1, 'first') +cool_start;
    if isempty(cool_stop)			%  cooling没有冷却到25度时 通过斜率判断是否稳定,0.2也是绘制斜率曲线后决定的。
        cool_stop  = find(T1_slope_smooth(index)<0.3 & T1_slope_smooth(index)>0.2, 1, 'first') +cool_start;
        if isempty(cool_stop)		% 如果没有 0.3  0.2之间的数,再次改变选取精度范围
            cool_stop  = find(T1_slope_smooth(index)<0.3 & T1_slope_smooth(index)>0, 1, 'first') +cool_start;
        end
    end
    
    cool_time(i)  = Time(cool_stop) - Time(cool_start);
    cool_T(i,1)  = T1(cool_start);
    cool_T(i,2)  = T1(cool_stop);
    cool_ind(i,1)= cool_start;
    cool_ind(i,2)= cool_stop;

    ind_2 = cool_stop;
      


% idx = heat_ind(i,1):heat_ind(i,2);
% plot(idx, T1(idx), '--r', 'LineWidth', 1.2);
% idx = cool_ind(i,1):cool_ind(i,2);
% plot(idx, T1(idx), '--b', 'LineWidth', 1.5);
% disp('---')
% pause(0.5)


end

实验结果在 struct 中,怎么排序

结构体转table,然后利用 sortrows() 排序,参考MATLAB 矩阵按不同行列排序

实验结果

下图中红色虚线是提取的加热阶段,蓝色虚线是选取的冷却阶段。蓝色虚线和红色虚线是有间隔的。通过调参可以控制加热夹断的选取和冷却阶段的选取。
在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值