按照两因素进行统计

对变量Var1需要按照按照Var2(15类)和Var3(2类)两因素分别进行统计,需要把Var2和Var3两列变量的序数和成一个序数。然后再进行统计。


tb=table(ET0S15.P,ET0S15.fre1,crop);
Var2_n=unique(tb.Var2);
y=zeros(15,2) %绘制柱状图要准备的数据,按照Var2和Var3两因素统计
for i=1:15
for j=1:2
idx=find(tb.Var2==Var2_n(i) & tb.Var3==j);
y(i,j)=sum(tb.Var1(idx));
end
end

Leave a Reply

Your email address will not be published. Required fields are marked *