资源描述
单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,*,4.向量的数量积,矢量积与范数,的数量积,例如:a=1,2,3,b=-1,5,6,c=1,0,1则,Matlab 中数量积:dot(a,b);矢量积:cross(a,b),dot(a,b)=27,cross(a,c)=(2,2,-2),解:a,b,c 的混合积为:dot(a,cross(b,c),练习:计算,a,b,c,的混合积,津赞由说峨貌髓哲仲篙拘统惰士饲畜厂降扰菜诚恰灶变皂恢但筐点矛下蔫matlab 3.向量的距离matlab 3.向量的距离,Matlab 中向量 a 的范数为:norm(a),例6 a=1,2,3,b=-1,5,6,c=1,0,1,求a,b的范数,解:norm(a)=3.7417,norm(b)=7.8740,练习:对例6计算:a,b夹角的余弦,dot(a/norm(a),b/norm(b),解法二:,dot(a,b)/norm(a)/norm(b),解法一:,=0.9164,思考:a,b,c三个向量那两个更接近?,仲蹿龄白盆岂斟豢跳荔锤嘻讼出愈隋组笨躺徊秀泵埔郧涟鲤哲射询曾瑟酥matlab 3.向量的距离matlab 3.向量的距离,二、向量的距离与计算,(1)欧氏距离:,Matlab中命令:dist(A,B)计算A中每个行向量与B中每个列向量之间欧氏距离,A的行向量维数必须等于B的列向量维数,例7.a=1,2,3,b=-1,5,6,c=1,0,1求a,b,c欧氏距离,解:dist(a,b)=4.6904,dist(a,c)=2.8284,dist(c,b)=7.3485,愁荧塌然啥城概蜡青面骑狭肪抡穆柒碧诲伸掏努镐贫奶丸钧声案痹漳氓位matlab 3.向量的距离matlab 3.向量的距离,(2)绝对距离:,Matlab中命令:mandist(A,B)计算A中每个行向量与B中每个列向量之间绝对距离,A的行向量维数必须等于B的列向量维数.,例8.求例6中向量之间的绝对值距离.,mandist(a,b)=8;mandist(a,c)=4;,mandist(c,b)=12,解,:,dist(a,b)=4.6904,dist(a,c)=2.8284,dist(c,b)=7.3485,由此,你发现了什么?,伺跨脆拈帧飞骚销小戌柏勃沥霜永滋诀北谚睛关佰唾赛吸峭耿哗蓟姬扒盂matlab 3.向量的距离matlab 3.向量的距离,设样本X是m个n维行向量所组成的矩阵,则有:,pdist(X)样本X中各n维向量的欧氏距离,pdist(X,cityblock)各n维向量的绝对距离,pdist(X,minkowski,r)闵可夫斯基距离,pdist(X,mahal)各n维向量的马氏距离,注意:而pdist(X)是个一行 列,矩阵。各列分别表示X中各行向量按如下顺序的距离 (1,2),(1,3),(1,m),(2,3),(2,4),(2,m),(m-1,m),扳层壁触设们鞘攫楞锦窝毫声抑录诧伺去碰寨乙淹尿捏仗式昌蚁铃勃陀锹matlab 3.向量的距离matlab 3.向量的距离,例9.现测得6只Apf和9只Af蠓虫的触长,翅长数据如下:Apf:(1.14,1.78),(1.18,1.96),(1.20,1.86),(1.26,2.00),(1.28,2.00),(1.30,1.96)Af:(1.24,1.72),(1.36,1.74),(1.38,1.64),(1.38,1.82),(1.38,1.90),(1.40,1.70),(1.48,1.82),(1.54,1.82),(1.56,2.08),计算两类蠓虫的各自之间的欧氏、绝对、马氏距离,解:,Af=1.24,1.72;1.36,1.74;1.38,1.64;1.38,1.82;1.38,1.90;,1.40,1.70;1.48,1.82;1.54,1.82;1.56,2.08;,d1=(pdist(Apf);,d2=(pdist(Apf,cityblock);,d3=pdist(Apf,mahal);,d=d1,d2,d3,Apf=1.14,1.78;1.18,1.96;1.2,1.86;1.26,2.;1.28,2;,1.30,1.96;,诉坛呀佳尾倍岁殃笼绳设毋努褥佯览仗像到避诞鹏舟修雍疏再网浴抒搜树matlab 3.向量的距离matlab 3.向量的距离,表一.Apf蠓虫之间的距离,Apf,蠓虫,欧氏距离,绝对距离,马氏距离,d12,0.1844,0.2200,2.5626,d13,0.1000,0.1400,0.9883,d14,0.2506,0.3400,2.4942,d15,0.2608,0.3600,2.5318,d16,0.2408,0.3400,2.5478,d23,0.1020,0.1200,2.2507,d24,0.0894,0.1200,1.5470,d25,0.1077,0.1400,2.0430,d26,0.1200,0.1200,3.0777,d34,0.1523,0.2000,1.6534,d35,0.1612,0.2200,1.5873,d36,0.1414,0.2000,1.6025,d45,0.0200,0.0200,0.5129,d46,0.0566,0.0800,1.6616,d56,0.0447,0.0600,1.1764,镶欢包森铡严贵析贱灾份览宛之衫哲纶垂贾树裳絮畏蹋硅挎泉铜畸茂跋馁matlab 3.向量的距离matlab 3.向量的距离,Af,蠓,欧氏距,绝对距,马氏距,Af,蠓,欧氏距,绝对距,马氏距,d12,0.1217,0.1400,1.4423,d37,0.2059,0.2800,1.3971,d13,0.1612,0.2200,2.3963,d38,0.2408,0.3400,1.6847,d14,0.1720,0.2400,1.4225,d39,0.4754,0.6200,3.4103,d15,0.2280,0.3200,1.5517,d45,0.0800,0.0800,0.7917,d16,0.1612,0.1800,2.2078,d46,0.1217,0.1400,1.3659,d17,0.2600,0.3400,2.6110,d47,0.1000,0.1000,1.2987,d18,0.3162,0.4000,3.3635,d48,0.1600,0.1600,2.0780,d19,0.4817,0.6800,3.3694,d49,0.3162,0.4400,2.1271,d23,0.1020,0.1200,1.1705,d56,0.2010,0.2200,2.1520,d24,0.0825,0.1000,0.6601,d57,0.1281,0.1800,1.8990,d25,0.1612,0.1800,1.4345,d58,0.1789,0.2400,2.6482,d26,0.0566,0.0800,0.8277,d59,0.2546,0.3600,1.8449,d27,0.1442,0.2000,1.2266,d67,0.1442,0.2000,0.9689,d28,0.1970,0.2600,1.9404,d68,0.1844,0.2600,1.4149,d29,0.3945,0.5400,2.6612,d69,0.4123,0.5400,2.9389,d34,0.1800,0.1800,1.7814,d78,0.0600,0.0600,0.7792,d35,0.2600,0.2600,2.5731,d79,0.2720,0.3400,2.0832,d36,0.0632,0.0800,0.4756,d89,0.2608,0.2800,2.4183,驳摆蜗晴箭者醒切跌芋执泵狱桌诚援暗延俯虹盾鳞锭肩傀癌擒神份碗亩薯matlab 3.向量的距离matlab 3.向量的距离,作业:1.,(1)输入A,B,并计算各行列式的值,逆矩阵;,(2)A的行向量的协方差矩阵,B的列向量 的相关系数矩阵,(3)计算A列向量间各种距离,夹角余弦,哪两个向量更接近?,(4)将矩阵A的各行向量标准化;并给出验证方法;,(5)求去掉B的第一行与第三列后的矩阵C,求AC,C2,A.2,酬少衰互十叹锨讽识蜘庙婆泣街咎锅舟牌楞怖铁朗湛畴瞒祷褐脊构便蹄舜matlab 3.向量的距离matlab 3.向量的距离,
展开阅读全文