参考链接:http://bbs.pinggu.org/thread-3777396-1-1.html
smoothts函数
调用格式:
output = smoothts(input)
output = smoothts(input, ‘b’, wsize) % 盒子法
output = smoothts(input, ‘g’, wsize, stdev) % 高斯窗方法
output = smoothts(input, ‘e’, n) % 指数法
【例7.1-2】现有上海股市日开盘价、最高价、最低价、收盘价、收益率等数据,时间跨度为2005年1月4日至2007年4月3日,共510组数据。完整数据保存在文件examp7_1_2.xls中,其中部分数据如下图所示。试调用smoothts函数对日收盘价数据进行平滑处理
绘制日收盘价曲线图:
% 从文件examp7_1_2.xls中读取数据
>> x = xlsread('examp7_1_2.xls');
>> price = x(:,4)'; % 提取矩阵x的第4列数据,即收盘价数据
>> figure; % 新建一个图形窗口% 绘制日收盘价曲线图,黑色实线,线宽为2
>> plot(price,'k','LineWidth',2); % 为X轴和Y轴加标签
>> xlabel('观测序号');
>> ylabel('上海股市日收盘价');
盒子法:
% 用盒子法平滑数据,窗宽为30