数学建模常用的Matlab绘图总结_matlab绘图方法总结

2020-02-27 其他工作总结 下载本文

数学建模常用的Matlab绘图总结由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“matlab绘图方法总结”。

饼状图

Expenses = [20 10 40 12 20 19 5 15];

ExpenseCategories = {'Food','Medical','Lodging','Incidentals',...'Transport','Utilities','Gifts','Shopping'};

MostLeastExpensive =(Expenses==max(Expenses)|Expenses==min(Expenses));

h=pie(gca,Expenses,MostLeastExpensive,ExpenseCategories);

ShoppingGiftsFoodMedicalUtilitiesTransportLodgingIncidentalsExpenses = [20 10 40 12 20 19 5 15];

MostLeastExpensive =(Expenses==max(Expenses)|Expenses==min(Expenses));

h=pie(gca,Expenses,MostLeastExpensive);legend('Food','Medical','Lodging','Incidentals',...'Transport','Utilities','Gifts','Shopping');

4%FoodMedicalLodgingIncidentalsTransportUtilitiesGiftsShopping

14%11%7%13%14%28% 9% Expenses = [20 10 40 12 20 19 5 15];

MostLeastExpensive = [0 1 0 1 0 1 0 1];%分割 h=pie(gca,Expenses,MostLeastExpensive);legend('Food','Medical','Lodging','Incidentals',...'Transport','Utilities','Gifts','Shopping');

11%14%4%7%13% FoodMedicalLodgingIncidentalsTransportUtilitiesGiftsShopping28%14% 9%

x = [20 10 40 12 20 19 5 15];explode = [4 2 2 2 2 4 2 2];label = {'Food','Medical','Lodging','Incidentals',...'Transport','Utilities','Gifts','Shopping',}';figure('color','w','renderer','openGL');h = pie3(x,explode);h = findobj(h,'Type','text');set(h,{'string'},cellfun(@strcat,get(h,{'string'}),label,'un',0),'FontName','Times New Roman','FontSize',16);%set(h,{'string'},strcat(get(h,{'string'}),label));

%cm = [72 65 137;143 184 58;193 60 49;41 121 201;...%

150;189 84 58;193 160 90;241 121 101]/255;colormap(jet), shading interp view(18,20), camproj perspective light('Position',[1 2 3],'Style','inf')lighting gouraud

x = [20 10 40 12 20 19 5 15];explode = [4 2 2 2 2 4 2 2];label = {'14% Food','7% Medical','28% Lodging','9% Incidentals',...'14% Transport','13% Utilities','4% Gifts','11% Shopping',}';figure('color','w','renderer','openGL');pie3s(x,'Explode',explode,'Labels',label)%见Matlab_pie3s

直方图

Y = round(rand(5,3)*10);figure;subplot(2,2,1);bar(Y,'grouped');title('Group')subplot(2,2,2);bar(Y,'stacked');title('Stack')subplot(2,2,3);bar(Y,'histc');title('Histc')subplot(2,2,4);bar(Y,'hist');title('Hist')Group105100123Histc10501050450123Hist453020Stack1234512345

stream = RandStream('mrg32k3a','Seed',4);y1 = rand(stream,10,5);hb = bar(y1,'stacked');colormap(summer);hold on y2 = rand(stream,10,1);set(gca,'FontSize',14,'FontName','Times New Roman')hp = plot(1:10,y2,'marker','square','markersize',12,...'markeredgecolor','y','markerfacecolor',[.6,0,.6],...'linestyle','-','color','r','linewidth',2);hold off legend([hb,hp],'Carrots','Peas','Peppers','Green Beans',...'Cucumbers','Eggplant','Location','SouthEastOutside')3.532.521.510.50 12345678910CarrotsPeasPeppersGreen BeansCucumbersEggplant Data = [1,-2,3,1,-1,-2 4 2 3];DataP = Data;DataN = Data;DataP(Data 0)= 0;figure;bar(DataP,0.5,'k','EdgeColor','k');hold on;bar(DataN,0.5,'b','EdgeColor','b');43210-1-2123456789

Y = round(rand(5,3)*10);figure;subplot(2,2,1);bar3(Y,'grouped');

title('Group','FontSize',14,'FontName','Times New Roman')subplot(2,2,2);bar3(Y,'stacked');

title('Stack','FontSize',14,'FontName','Times New Roman')subplot(2,2,3);bar3(Y,'histc');

title('Histc','FontSize',14,'FontName','Times New Roman')subplot(2,2,4);bar3(Y,'hist');

title('Hist','FontSize',14,'FontName','Times New Roman')

Group1020Stack***Histc1010Hist***45123

杆状图

Data = [1,-2,3,1,-1,-2 4 2 3];DataP = Data;DataN = Data;DataP(Data 0)= NaN;figure;stem(DataP,'k');hold on;stem(DataN,'b');43210-1-2123456789Data = [1,-2,3,1,-1,-2 4 2 3];DataP = Data;DataN = Data;DataP(Data 0)= NaN;figure;stem(DataP,'k','fill');hold on;stem(DataN,'b','fill');4

3210-1-2123456789 Data = [1,-2,3,1,-1,-2 4 2 3];DataP = Data;DataN = Data;DataP(Data 0)= NaN;figure;stem(DataP,':diamondk','fill');hold on;stem(DataN,':diamondr','fill');43210-1-2123456789

Data = [1,-2,3,1,-1,-2 4 2 3];DataP = Data;DataN = Data;DataP(Data 0)= NaN;figure;stem(DataP,'LineStyle','-.','MarkerFaceColor','k','MarkerEdgeColor','green');hold on;stem(DataN,'LineStyle','-.','MarkerFaceColor','red','MarkerEdgeColor','green');4

3210-1-2123456789

三维图形

figure;[X,Y] = meshgrid(-15:.5:15,-12:.5:12);%X belongs to [-15,15] and Y belongs to [-12,12].R = sqrt(X.^2 + Y.^2)+ eps;Z = sin(R)./R;mesh(Z);%surf(X,Y,Z)

xlabel('X','FontSize',14,'FontName','Times New Roman')ylabel('Y','FontSize',14,'FontName','Times New Roman')zlabel('Z','FontSize',14,'FontName','Times New Roman')title('3-D space','FontSize',16,'FontName','Times New Roman')

3-D space by mesh10.5Z0-0.***203040506070YX

figure;X=-12:0.5:12;Y=-12:0.5:12;%surf绘图时,X,Y可以是一维向量,也可以是二维矩阵 R=ones(length(X),length(Y));for i=1:length(X)

for j=1:length(Y)

R(i,j)= sqrt(X(i).^2 + Y(j).^2)+eps;

end end

Z = sin(R)./R;surf(X,Y,Z);xlabel('X','FontSize',14,'FontName','Times New Roman')ylabel('Y','FontSize',14,'FontName','Times New Roman')zlabel('Z','FontSize',14,'FontName','Times New Roman')title('3-D space by surf','FontSize',16,'FontName','Times New Roman')

3-D space by surf10.5Z0-0.5151050-5-10-15-15-10-5051015YX

figure;[X,Y] = meshgrid(-15:.5:15,-12:.5:12);%X belongs to [-15,15] and Y belongs to [-12,12].R = sqrt(X.^2 + Y.^2)+ eps;Z = sin(R)./R;plot3(X,Y,Z);xlabel('X','FontSize',14,'FontName','Times New Roman')ylabel('Y','FontSize',14,'FontName','Times New Roman')zlabel('Z','FontSize',14,'FontName','Times New Roman')title('3-D space by plot3','FontSize',16,'FontName','Times New Roman')

3-D space by plot310.5Z0-0.5151050-5-10-5051015Y-15-15-10X

数学公式、符号和希腊字母的输入命令

Character Sequence alpha beta gamma delta epsilon zeta eta theta vartheta iota kappa lambda mu nu xi pi rho sigma varsigma tau equiv Im otimes cap supset int rfloor lfloor perp wedge rceil vee langle Symbol α β γ δ ɛ δ ε Θ ϑ ι κ λ µ ν ξ π π σ ρ τ ≡ ℑ

⊗ ∩ ⊃

∫ ë û ⊥

ù ∨ ∠

Character Sequence upsilon phi chi psi omega Gamma Delta Theta Lambda Xi Pi Sigma Upsilon Phi Psi Omega forall exists ni cong approx Re oplus cup

subseteq in lceil cdot neg times surd varpi rangle

Symbol ς Φ σ τ υ Γ Δ Θ Λ Ξ Π Σ ϒ Φ Ψ Ω ∀ ∃ ∍ ≅ ≈ ℜ ⊕ ∪

⊆ ∈ é · ¬ x √ ϖ ∠ Character Sequence sim leq infty clubsuit diamondsuit heartsuit spadesuit leftrightarrow leftarrow uparrow rightarrow downarrow circ pm geq propto partial bullet div neq aleph wp oslash supseteq subset o nabla ldots prime mid

copyright

Symbol ~ ≤ ∞ ♣ ♦ ♥ ♠ ↔ ← ↑ → ↓ º ± ≥ ∝ ∂ • ÷ ≠ ℵ ℘ ∅ ⊇ ⊂ ο ∇...´ ∅

| ©

图形标注

set(gca,'FontSize',10, 'FontName','Arial')xlabel('test','FontSize',10,'FontName','Arial')ylabel('test','FontSize',10,'FontName','Arial')legend('test','FontSize',10,'FontName','Arial')title('test','FontSize',13,'FontName','Times New Roman')r(red)红色

G(green)绿色

b(blue)蓝色

c(cyan)青色

M(magenta)品红

y(yellow)黄色

k(black)黑色

w(white)+ 加号

o(字母)小圆圈

* 星号

.实点

x 叉号 d 棱形

^ 上三角形

v 下三角形 colormap(jet)

坐标控制

axis函数 的调用格式为:

axis([xmin xmax ymin ymax zmin zmax])axis square:产生正方形坐标系(缺省为矩形)axis auto:使用缺省设置 axis off:取消坐标轴 axis on:显示 坐标轴 grid on:加网格线

白色

《数学建模常用的Matlab绘图总结.docx》
将本文的Word文档下载,方便收藏和打印
推荐度:
数学建模常用的Matlab绘图总结
点击下载文档
相关专题 matlab绘图方法总结 建模 常用 数学 matlab绘图方法总结 建模 常用 数学
[其他工作总结]相关推荐
    [其他工作总结]热门文章
      下载全文