%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
function Red=mm_Red(data)%盲目约简算法,返回值为约简结果
[data_c,data_r]=size(data);
Red=data;
Red(data_c+1,data_r)=0;
[ind_data_num,ind_data_r]=size(myind(data));
[ind_Red_num,ind_Red_r]=size(myind(Red));
[Red_c,Red_r]=size(Red);
while((norm(Red(data_c+1),:)-ones(1,Red_r))~=0)
a=randint(1,1,[1,Red_r]);
if(Red(data_c+1,a)==0)
c=Red;
Red(:,a)=[];
[ind_Red_num,ind_Red_r]=size(myind(Red(1:data_c,:)));
if(ind_data_num==ind_Red_num)
[Red_c,Red_r]=size(Red);
else
Red=c;
Red(data_c+1,a)=1;
[Red_c,Red_r]=size(Red);
end
end
end
Red=Red(1:data_c,:);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function C=myind(a)%求划分函数
b=a;
c=intersect(a,b,'rows');
[m,n]=size(c);
[p,q]=size(a);
%C=[];
C={};
for i=1:m
z=c(i,:);
A=[];
for j=1:p
x=a(j,:);
if(ismember(z,x,'rows')==1)
A=[A j];
end
%C(i,1:length(A))=A;
C{i,1}=A;
end
end
1.JPG
(16.58 KB, 下载次数: 0)
2017-4-27 19:41 上传