乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > 求!!!怎么用<em>MATLAB</em>给指定区域填充颜色?在y1=1-x...

求!!!怎么用<em>MATLAB</em>给指定区域填充颜色?在y1=1-x...

作者:乔山办公网日期:

返回目录:excel表格制作


t=0:0.01:2*pi;

y=sin(t);

y2=y+2;

plot(t,y,t,y2,'r');

hold on% 如果t的维数较小,可以加细。

n=length(t);

for i=1:nx1=[t(i),t(i)];

y1=[y(i),y2(i)];

plot(x1,y1,'k');

end



可这zd
x=-1:0.01:1;
y1=1-x;y2=x+1;y3=zeros(size(x));
plot(x, y1, x, y2,x,y3),hold on
x1=-1:0.01:0;x2=0.01:0.01:1;
z1=x1+1;z2=1-x2;
z=[z1 z2];
area(x,z,'FaceColor','b')
hold off

clear all
[X,Y] = meshgrid(-3:.0625:3);
Z = peaks(X,Y);%生成数据z
[x,y]=meshgrid(1:97);%为了举例方便生成坐标
figure(1)
mesh(x,y,Z);
colorbar


xR=[10,50];%设置x范围
yR=[40,50];%设置y范围

z1=Z.*(x>=xR(1)&x<=xR(2))&(y>=yR(1)&y<=yR(2));%为取出设定范围数据重新赋值而得到逻辑数组
z2=Z;%为不覆盖原始Z,新建变量
z2(z1(:)==1)=-5;%设定范围改为蓝色
%对取出范围内的数据重新赋值,生成用于着色的数组
%由于mesh函数不管怎样都只能用同一个colormap,所以你能改变的颜色必须在你使用的colormap中
%在figure(1)中的colorbar中读取颜色对应的值,可以大约的估计,6,3,-1,-5可以对应红,黄,孔雀蓝,蓝色。
%如果你要改变的颜色不在你所用的colormap中,那你只能编辑colormap了。例如黑zhidao色,不在jet中,你就要自己编辑了。


figure(2)
mesh(x,y,Z,z2);
colorbar



使用fill函数,具体的方法是
fill(x,y,c)
其中区域是使用x和y来指定,c来指定颜色
例如fill([0 1 1 0],[0 0 1 1],'r')是给一个矩形区域填充红色

FILL(X,Y,C) fills the 2-D polygon defined by vectors X and Y
with the color specified by C. The vertices of the polygon
are specified by pairs of components of X and Y. If necessary,
the polygon is closed by connecting the last vertex to the first.

If C is a single character string chosen from the list 'r','g','b',
'c','m','y','w','k', or an RGB row vector triple, [r g b], the
polygon is filled with the constant specified color.

祝你学习愉快e5a48de588b6e799bee5baa6363

相关阅读

关键词不能为空
极力推荐
  • 右键怎么没有导出到Microsoft office exce...

  • MICROSOFT OFFICE 2003 里面就已经包含了zdExcel,但如果你的控制面板里面找不到的话,证明程序组件有损坏。 建议内你容重新安装一下Office就可以,另外建议你安装Office 2010。启动任何一个

聚合标签

ppt怎么做_excel表格制作_office365_word文档_365办公网