用matlab画饼图

2024-11-28 10:36:59
推荐回答(2个)
回答1:

A=[0.5,1,2,2.3,10,8.8,4]
f1=A(find(A<2&A>=0))
f2=A(find(A<6&A>=2))
f3=A(find(A>=6))
ratio=[length(f1) length(f2) length(f3)]/length(A)
format rat
ratio
pie(ratio)
legend('0-2','2-6','>6')

结果:
A =

0.5000 1.0000 2.0000 2.3000 10.0000 8.8000 4.0000

f1 = 0.5000 1.0000

f2 = 2.0000 2.3000 4.0000

f3 = 10.0000 8.8000

ratio = 0.2857 0.4286 0.2857

ratio = 2/7 3/7 2/7

回答2:

pie 二维饼图 pie3