摘要: function a_ed = arraysort(a)%冒泡排序法for i =1:length(a)-1 %进行多少次比较 for j=1+i:length(a) %每次求出最大的数,放在最后 if(a(j)<a(i)) tem = ... 阅读全文
posted @ 2014-10-31 20:53 meiyouor 阅读(546) 评论(0) 推荐(0) 编辑
摘要: function [m,n] = stamatrix(a)%网上找到的方法,感觉很巧妙x=a(:);x=sort(x);d=diff([x;max(x)+1]);count = diff(find([1;d]));%列出每个元素出现的个数m = x(find(d));%列出a中出现的元素n = co... 阅读全文
posted @ 2014-10-31 20:49 meiyouor 阅读(591) 评论(0) 推荐(0) 编辑
摘要: function count = andian(a)v = max(a,[],2);count = 0;for i=1:length(v) [r2,c2] = find(a==v(i)); mi = min(a(:,c2)); if(v(i) == mi) count = v... 阅读全文
posted @ 2014-10-31 20:45 meiyouor 阅读(1503) 评论(0) 推荐(0) 编辑
摘要: 求矩阵的模:function count = juZhenDeMo(a,b)[r,c] = size(a);%求a的行列[r1,c1] = size(b);%求b的行列count = 0;for j=1:r-r1+1%所求的行数中取 for i=1:c-c1+1%所有的列数中取 ... 阅读全文
posted @ 2014-10-31 20:43 meiyouor 阅读(6341) 评论(0) 推荐(0) 编辑
摘要: 最大公约数:(函数)function n = zuidagongyueshu(a,b)if(a>b) tem = a; b = a; a = tmp;endfor i=1:a c = rem(b,a); if(c == 0) n = a; b... 阅读全文
posted @ 2014-10-31 20:39 meiyouor 阅读(8940) 评论(0) 推荐(1) 编辑