作业

demo1:Creating 2-D Plots

这个例子显示了如何创建MATLAB各种二维图

线图

第一步:The plot function creates simple line plots of x and y values.绘图函数创建x和y值的简单行图。

figure
x = 0:0.05:5;
y = sin(x.^2);
plot(x,y)

Line plots can display multiple sets of x and y data.利用线图可以显示多套x和y数据

y1 = sin(x.^2);
y2 = cos(x.^2);
plot(x,y1,x,y2)

第二个:Bar Plots

The bar function creates vertical bar charts. The barh function creates horizontal bar charts.利用bar函数可以创建垂直条形图,利用barth条形图可以创建水平条形图

x = -2.9:0.2:2.9;设定x轴范围
y = exp(-x.*x);  设定y轴范围
bar(x,y)

Stairstep Plots 阶梯图

The stairs function creates a stairstep plot. It can create a stairstep plot of Y values only or a stairstep plot of x and yvalues.stairs 函数的作用是创建一个阶梯图。它可以创建一个阶梯图的y值或阶梯图的X和Y值。
Polar Plots 极坐标图
The polar function draws a polar plot of angle (in radians) versus radius.极polar函数绘制极坐标图的角度(弧度)与半径。
theta = 0:0.01:2*pi;                      % angle 取出角度
rho = abs(sin(2*theta).*cos(2*theta));    % radius  取出半径
polar(theta,rho)

Scatter Plots 散点图
The scatter function draws a scatter plot of x and y values scatter函数绘制x和y值的散点图
load patients Height Weight Systolic    % load data  加载数据
scatter(Height,Weight)                  % scatter plot of Weight vs. Height  作出重量与高度关系的散点图
 
demo2 :画出matlab的图标
教你如何使用matlab画出matlab的logo
Use the membrane command to generate the surface data for the logo 使用 membrance 命令生成标识的表面数据
L = 160*membrane(1,100);
Create a figure and an axes to display the logo. Then, create a surface for the logo using the points from the membranecommand. Turn off the lines in the surface. 创建一个图形和一个轴来显示这个logo。然后,创建一个表面使用从membrane 命令产生的点。关闭表面上的线
f = figure;
ax = axes;

s = surface(L);
s.EdgeColor = 'none';
view(3)

Adjust the axes limits so that the axes are tight around the logo 调整轴的限制,使轴可以紧贴这个logo
 
 
ax.XLim = [1 201];
ax.YLim = [1 201];
ax.ZLim = [-53.4 160];



Adjust the view of the logo using the camera properties of the axes. Camera properties control the view of a three dimensional scene like a camera with a zoom lens.
使用轴的camera属性调整这个logo的视图。camera属性控制的三维场景像相机带有变焦镜头。
ax.CameraPosition = [-145.5 -229.7 283.6];
ax.CameraTarget = [77.4 60.2 63.9];
ax.CameraUpVector = [0 0 1];
ax.CameraViewAngle = 36.7;

Change the position of the axes and the xy, and z aspect ratio to fill the extra space in the figure window 更改轴的位置和x、y和z纵横比以填充图形窗口中的额外空间
ax.Position = [0 0 1 1];
ax.DataAspectRatio = [1 1 .9];

Create lights to illuminate the logo. The light itself is not visible but its properties can be set to change the appearance of any patch or surface object in the axes. 
创建灯光去让标志变亮。光本身是不可见的,但它的属性可以被设置为改变任何在轴上的物体。
  
  
l1 = light;
l1.Position = [160 400 80];
l1.Style = 'local';
l1.Color = [0 0.8 0.8];

l2 = light;
l2.Position = [.5 -1 .4];
l2.Color = [0.8 0.8 0];


 
Change the color of the logo.改变这个logo的颜色

s.FaceColor = [0.9 0.2 0.2];


Use the lighting and specular (reflectance) properties of the surface to control the lighting effects 使用表面的光照和反射属性来控制照明效果

s.FaceLighting = 'gouraud'; 面照明
s.AmbientStrength = 0.3; 环境强度
s.DiffuseStrength = 0.6; 弥漫强度
s.BackFaceLighting = 'lit';表面照明

s.SpecularStrength = 1; 镜面强度
s.SpecularColorReflectance = 1; 镜面颜色
s.SpecularExponent = 7; 镜面指数

 
 
Turn the axis off to see the final result 关这个轴去看最后的结果 















评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值