function processed_signal = process_signal(peak_signal)
num_samples = length(peak_signal); % 获取输入信号的长度
processed_signal = zeros(num_samples, 1); % 初始化输出信号为零
% 找到峰值点
peak_times = find(peak_signal); % 找到所有峰值点的时间索引
if isempty(peak_times)
return; % 如果没有峰值点,直接返回
end
% 线性上升到达每个峰值点
for i = 1:length(peak_times)
peak_index = peak_times(i);
peak_height = peak_signal(peak_index);
% 计算线性上升的斜率
slope = peak_height / peak_index; % 斜率 = 峰值高度 / 达到峰值的点数
% 应用线性上升
for j = 1:peak_index
processed_signal(j) = slope * j;
end
end
% 由于在每个峰值点后信号立即下降到0,我们不需要额外的代码来设置为0
end