matlab绘制简单图像

plot

plot绘制的是二维图像。

注意,自变量x开始:间隔:结束 这样设置。

% 设置曲线
>> x=0:pi/10:2*pi;
>> y1=sin(x);
>> y2=cos(x);

>> plot(x,y1,x,y2) % 一张图多条曲线
>> xlabel('x','fontsize',12);
>> ylabel('y','fontsize',12);
>> title('sin&cos','fontsize',12);
>> plot(x,y1,'LineWidth',1); % 调节粗细

% 另一种绘制多条曲线的方法
>> plot(x,y1);
>> hold on
>> plot(x,y2);
>> hold on

在这里插入图片描述

subplot

subplot(m,n,p)中指定了m行n列的图形,p代表绘制时某一特定图形的位置。
示例如下:

figure;
subplot(3,1,1);
plot(pluseWave_ICA(1,:),'LineWidth',2,'color','red');
title('pluseWave ICA 1');

subplot(3,1,2);
plot(pluseWave_ICA(2,:),'LineWidth',2,'color','green');
title('pluseWave ICA 2');

subplot(3,1,3);
plot(pluseWave_ICA(3,:),'LineWidth',2,'color','blue');
title('pluseWave ICA 3');

plot3

使用plot3函数绘制三维曲线。
clf是用来清除图形的命令,画图之前用。不清除的话会残留上个图像。

>> clf
>> x=0:pi/10:2*pi;
>> y1=sin(x);
>> y2=cos(x);

>> plot3(y1,y2,x,'m:p')
>> grid on % 打开网格

>> xlabel('Dependent Variable Y1')
>> ylabel('Dependent Variable Y2')
>> zlabel('Independent Variable X')
>> title('Sine and Cosine Curve')

在这里插入图片描述

surf

使用surf函数生成曲面。
先用meshgrid函数进行网格化,生成矩阵。
eps一般用在分母上,防止分母为0。是matlab中最小的正数。
运算符前加点表示点运算。

>> x=-7.5:0.5:7.5;y=x;
>> [X,Y]=meshgrid(x,y);
>> R=sqrt(X.^2+Y.^2)+eps;
>> Z=sin(R)./R;

>> surf(X,Y,Z)
>> xlabel('X 轴方向')
>> ylabel('Y 轴方向')
>> zlabel('Z 轴方向')

在这里插入图片描述

隐函数

之前遇到隐函数的问题,在网上找了很久都没找到相关的,后来又查阅了文档。
写法如下:

f = @(x,y,z) x.^2 + y.^2 - z.^2;
fimplicit3(f)

效果:
在这里插入图片描述

图像参数

摘自知乎。
在这里插入图片描述

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值