码迷,mamicode.com
首页 > 其他好文 > 详细

MATLAB 2D绘图

时间:2020-11-11 16:00:21      阅读:5      评论:0      收藏:0      [点我收藏+]

标签:name   end   roman   seconds   rgba   second   orm   info   src   

clc;close all;clear;
x =linspace(0,4*pi,10);
y = x.^2.*sin(x);
figure
hold on
plot(x,y,‘b-‘,‘linewidth‘,2)
plot(x,y,‘r^‘,‘linewidth‘,2)
xlabel(‘x (seconds)‘)
ylabel(‘y = x^2*sin(x)‘)
grid on
title(‘x VS y an example plot‘)
legend(‘y‘,‘y(data points)‘,‘location‘,‘best‘)
axis([min(x) max(x) min(y) max(y)])
text(2,-40,‘The angle of the wheel \theta‘,‘color‘,‘r‘,‘FontSize‘,16,‘FontName‘,‘Time News Roman‘)


% histogram 直方图
N = 2000;
numBins = 20;
sampleuniform = rand(1,N);
sampleNorm = randn(1,N);
figure
subplot(2,1,1)
histogram(sampleuniform,numBins);%numBins默认是10个
subplot(2,1,2)
histogram(sampleNorm,numBins);

%% plotyy 方便对变化范围差异较大的两幅图进行比较
x2 = linspace(0,5*pi,20);
y2 = x2.^3.*sin(x2);

figure
hold on
plot(x,y)
plot(x2,y2)

figure
plotyy(x,y,x2,y2)

%% semilogx
figure
semilogx(x2,y2)
grid on


%%loglog()
figure
x3 = logspace(-1,2);
%logspace(a,b)创建10^a到10^b之间分为50份默认的,logspace(a,b,n)创建10^a到10^b之间分为n份
loglog(x3,exp(x3),‘-s‘)
grid on

%% pie 饼图
figure
sales = [15 50 30 30 20];
pie(sales)

%% scatter
figure
subplot(2,1,1)
scatter(x,y)
subplot(2,1,2)
plot(x,y,‘b+‘)

 

技术图片

 技术图片

 技术图片

 技术图片

 技术图片

 技术图片

 技术图片

 

 技术图片

 

 

 

 

 

MATLAB 2D绘图

标签:name   end   roman   seconds   rgba   second   orm   info   src   

原文地址:https://www.cnblogs.com/csymemory/p/13764449.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!