程序练习:Matlab 饼图绘制
生活随笔
收集整理的這篇文章主要介紹了
程序练习:Matlab 饼图绘制
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Matalb小練習(xí)
練習(xí)餅圖繪制,目標(biāo)是畫出一個(gè)餅圖
可以展示三個(gè)產(chǎn)品市場份額的餅圖
代碼如下
function week13 %%餅圖 h0=figure('toolbar','none','position',[200 150 450 250],'name','week 13'); t=[54 21 35; 68 54 35; 45 25 12; 48 68 45; 68 54 69]; x=sum(t); h=pie(x); textobjs=findobj(h,'type','text'); str1=get(textobjs,{'string'}); val1=get(textobjs,{'extent'}); oldext=cat(1,val1{:}); names={'product1:';'product2:';'product3:'}; str2=strcat(names,str1); set(textobjs,{'string'},str2) val2=get(textobjs,{'extent'}); newext=cat(1,val2{:}); offset=sign(oldext(:,1)).*(newext(:,3)-oldext(:,3))/2; pos=get(textobjs,{'position'}); textpos=cat(1,pos{:}); textpos(:,1)=textpos(:,1)+offset; set(textobjs,{'position'},num2cell(textpos,[3,2]))運(yùn)行結(jié)果如下
總結(jié)
以上是生活随笔為你收集整理的程序练习:Matlab 饼图绘制的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql root命令_设置更改roo
- 下一篇: 编程练习:Matlab 一个小任务(-)