dukaibing 发表于 2009-8-9 12:13

用MATLAB建模--编程--源程序中疑问

在用MATLAB建模过程中遇到了下面的问题,望高手给予指导!谢谢

如下表所示:  

表1
城镇居民家庭平均每人全年购买的主要商品数量项目19851990199519992000粮食/Kg134.76130.729784.9182.31鲜菜/Kg144.36138.7116.47114.94114.74
编程实现不同年份之间数据向量的夹角余弦?
源程序如下:
C=;
d=1-pdist(C','cosine')





我的问题是:为什么要用    1-pdist(C','cosine'),   而直接用语句pdist(C','cosine')则算出的结果不对 ?

dukaibing 发表于 2009-8-10 11:27

1# dukaibing

我问了同学,知道答案了!
'cosine' - One minus the cosine of the included angle between observations (treated as vectors)


函数在计算的时候有个“one minus”的操作,再“one minus”一下,就是结果了。。
页: [1]
查看完整版本: 用MATLAB建模--编程--源程序中疑问