这个程序用来寻找输入的两组数据(x,y)的峰,并计算其半高全宽和其他参数。

开始比较容易懂,后来到了程序主体部分,看不明白,看了好长时间,可能因为知识结构不全面,看不懂了。希望再此能得到大家的帮助,多谢啦。

可能主要是程序的设计思路没有明白。

程序在下面附件中,不明白的部分用红字标出

function[output] = autopeak(x,y)

% INITIALIZATION初始化

% set detection sensitivity parameters设置灵敏度参数为黄金分割1.618

% the golden ratio seems to work exceptionally fine :)

nfwhms = 1.6180;%1.6180;半高全宽

nstds = 1.6180;%1.6180;标准偏差

% put signal to columns if not so yet检查输入信号

shape = size(x);

ifshape(2) > 1

x = x';

end

shape = size(y);

ifshape(2) > 1

y = y';

end

% smooth signal, determine its baseline and detection threshold平滑信号

y = smooth(y);

threshold = nstds * std(y);%设定阈值

% plot the signal

%画图

plot(x,y);

holdon;

%PEAKDETECTION RUNDOWN开始寻峰

% hunt the peaks down one by one and measure them依次寻峰并测量,之后从信号中删除,知道小于阈值

% then eliminate them from signal and repeat until threshold

fori = 1 : length(x)

% determine peak by global maximum找出最大值,并计算基准1(平均值)。

[peaki, ipeak] = max(y);

base(1) = mean(y);

% check if big enough, else stop

ifpeaki < threshold

break

end

% save the peak and plot it保存峰值并画出

peak(i) = peaki;

loc(i) = x(ipeak);

plot(loc(i),peak(i),'ro');

% determine fwhm

% by shifting signal twice and locating minimas on both sides

% do it in two steps: using global baseline (j=1) and fwhm-based local baseline (j=2)

%通过移动信号2次,来定位两侧的最小值:第一步,使用基准1;第二部使用FWHM的基准2.

forj = 1 : 2

% compute shifted signal by peak-baseline points

y_shift = abs(y - (peak(i) + base(j))/2);

x_shift = abs(x - loc(i));

y_shift2 = y_shift + x_shift * peak(i)/max(x_shift);

% determine both fwhm points on shifted signal by sequential

% elimination

[y_temp, ifwhms(1)] = min(y_shift2);

y_shift2(ifwhms(1)-20:ifwhms(1)+20) = y_shift2(ifwhms(1)-20:ifwhms(1)+20) + peak(i);

[y_temp, ifwhms(2)] = min(y_shift2);

% compute index fwhm difference and fwhm

idfwhms = abs(diff(ifwhms));

indfwhms = floor(nfwhms*idfwhms);

fwhm(i) = abs(x(ifwhms(2)) - x(ifwhms(1)));

% compute fwhm-based guess for local baseline

base(j+1) = (y(ipeak-indfwhms) + y(ipeak+indfwhms))/2;

end

% recompute peak value with local baseline

peak(i) = y(ipeak) - base(j);

% calculate total power in peak with local baseline

y_temp = y - base(j);

peakint(i) = sum(y_temp(ipeak-idfwhms:ipeak+idfwhms)) * diff(x(1:2));

% plot the area under the peak

fork = 0:idfwhms

plot([x(ipeak-k),x(ipeak-k)],[base(j),y(ipeak-k)],'r');

plot([x(ipeak+k),x(ipeak+k)],[base(j),y(ipeak+k)],'r');

end

% eliminate the peak from signal for rundown to proceed

y_temp = zeros(length(y),1);

y_temp(ipeak-indfwhms:ipeak+indfwhms) = y(ipeak-indfwhms:ipeak+indfwhms);

y = y - y_temp;

end

holdoff;

% OUTPUT PREPARATION

% create nice output matrix, sort peaks by location order and number them

output(:,2) = peak';

output(:,3) = loc';

output(:,4) = fwhm';

output(:,5) = peakint';

output = sortrows(output,3);

output(:,1) = (1:length(peak))';

[本帖最后由 edifiers2008 于 2009-1-21 09:49 编辑]

读懂matlab代码,一个Matlab的寻峰程序没有看懂,不知大家能否帮助?相关推荐

  1. java可以看懂php代码吗_PHP笔记——java程序员看懂PHP程序

    1.php是一种服务器端脚本语言,类型松散的语言. 2.<?php ?>xml风格 脚本风格 ?>简短风格 ASP风格 以;结尾: 3.注释: a)// b)# c)/**/ 4.变 ...

  2. matlab程序 如何使用,如何使用MATLAB创建一个最简单的程序

    <如何使用MATLAB创建一个最简单的程序>由会员分享,可在线阅读,更多相关<如何使用MATLAB创建一个最简单的程序(4页珍藏版)>请在人人文库网上搜索. 1.如何使用MAT ...

  3. 代码的简单就在于——直接能看懂

    我们经常会听到这样一句话--简单就是美,或者是这句话的各种变体,而且这句话不限于行业,不仅仅是在软件业,在各种涉及到设计艺术的领域,很多大师级的任务都会告诉我们,简单就是美. 在这里我当然只想针对软件 ...

  4. PHP笔记——java程序员看懂PHP程序

    PHP笔记--java程序员看懂PHP程序 php是一种服务器端脚本语言,类型松散的语言. <?php   ?>       xml风格 <script language=" ...

  5. 优雅的在latex中插入MATLAB代码 | 解决MATLAB代码中文乱码问题

    我们要使用的核心宏包是 listings 和 matlab-prettifier.其中 listings 是为了插入代码,matlab-prettifier 提供了很好的配色方案. 最小工作示例如下: ...

  6. rmse算法matlab代码,rmse matlab代码

    [2 4],:,index).^2); end %计算 RMSE RMS_ekf... RMSE 16 15 14 1 程序提示:将变量 x4 加进回归方程(Move ... 于是,在 Matlab ...

  7. php不会写 能看懂,学php很久了,为什么能看懂,但是老写不出来

    学php很久了,为什么能看懂,但是老写不出来 回复讨论(解决方案) 同求,练太少. 天天都是TNT中,或电影中,能学会才怪,哎.偶没得救了. 请问如果你整天岸边看别人游泳而去实践的话能学会游泳嘛? 恩 ...

  8. sip 时序图_教你如何看懂时序图(小白如何快速轻松的看懂时序图)

    操作时序永远是使用任何一片IC芯片的最主要的内容,看懂时序图,再操控这个芯片就非常容易了.而提取芯片器件手册上有用的信息是使用芯片的最基本步骤. 以液晶显示芯片1602为例 首先我们来看1602的引脚 ...

  9. 容积卡尔曼滤波(ckf)MATLAB代码(一个ckf滤波器的子程序)

    一个ckf滤波器的子程序,自己可以进行拓展,可以根据自己的实例进行套用,适用与多维实例的系统,代码注释全面,参数设置参考的文献均已注明,值得学习 %% ------------------------ ...

最新文章

  1. Jquery 之Ajax方法$.get() 的运用,扩展链接模型的天地
  2. mybatis源码分析(2)——事务概述
  3. python linux命令-Python执行Linux系统命令的4种方法
  4. Java版 QQ空间自动登录无需拷贝cookie一天抓取30WQQ说说数据流程分析【转】
  5. linux distribution timeline
  6. Jenkins配置Findbugs做源代码安全扫描
  7. 必填字段的自定义JSF验证器
  8. 推荐几十本投资书籍、互联网书籍及热门查看流量的工具
  9. 对当前目录及子目录下的所有源码文件及Makefile打包
  10. oracle中trunc x-1,oracle中trunc函数的说明
  11. 数组的连续最大子段和
  12. Jenkins:项目配置
  13. Macs Fan Control Pro for mac(电脑风扇控制软件)v1.5.10中文
  14. MATLAB信号处理仿真入门实验
  15. windows 10下解压.gz后缀文件
  16. CAB 写inf文件
  17. UVA 12304 计算几何+圆模板
  18. 在VM虚拟机上安装Red Hat Enterprise Linux
  19. win10计算机属性管理打不开,win10无法打开设置应用的两种解决方法【图文】
  20. SpringBoot整合j2cache缓存

热门文章

  1. 这些都是无轴螺旋输送机稳定运行的必要条件!
  2. Mac安装truffle框架时出现✓ Preparing to download box ✖ Downloading Unbox failed! Error: connect的解决方法
  3. 进入docker容器的方法
  4. 从键盘上输入一个数,判断是否为素数。
  5. 如何判断一个数是否素数
  6. 寄云一站式平台支持起医疗大数据的构建与运营
  7. Java基础(32)
  8. html5的video在IOS端默认全屏和黑屏问题
  9. js数组要用的方法:push、pop、unshift、shift、splice、reverse、sort、concat、join、slice、indexof、foreash、map、filter
  10. 微分方程求解matlab冲激信号,用Matlab求冲激响应的几种方法