Theoretical Intelligence分享 http://blog.sciencenet.cn/u/felonwan

博文

Matlab数据处理中遇到的两个小问题

已有 6408 次阅读 2013-3-18 09:42 |系统分类:科研笔记|关键词:学者| MATLAB, detrend, 删除列

版本R2012a Unix
1. 去趋势化函数
去趋势化函数detrend对一列和对一个矩阵处理的结果有差异,但是其说明里说是对矩阵每一列进行处理:
   Y = detrend(X) removes the best straight-line fit linear trend from the
   data in vector X and returns the residual in vector Y.  If X is a
   matrix, detrend removes the trend from each column of the matrix.
 
   Y = detrend(X,'constant') removes just the mean value from the vector X,
   or the mean value from each column, if X is a matrix.    

   Y = detrend(X,'linear',BP) removes a continuous, piecewise linear trend.
   Breakpoint indices for the linear trend are contained in the vector BP.
   The default is no breakpoints, such that one single straight line is
   removed from each column of X.
最后一句很可疑,难道是所有的列都移除了同样的一条直线?那么这条直线必然是全局拟合出来的了。看来保险起见,还是用一次处理一列为好,虽然速度上慢了很多。

2.一次删除掉两列的速度比分两一次每次分别删除掉一列的速度要慢
任务是要做循环,每次把从原矩阵取值特定的列到一个矩阵,使得这个矩阵比原矩阵少两列。
可以直接赋值,需要改变索引,这样速度居然最慢;还可以先反原矩阵全赋值给这个矩阵,再从这个矩阵里删除两列。
奇怪的是从这个矩阵里删除两列,居然一次删除两列比分两次每次删一列要慢上一些!




https://m.sciencenet.cn/blog-335776-671331.html

上一篇:非线性方程组的吸引域和分界线
下一篇:冲量定理与非自治微分方程的解

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-12 12:14

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部