(MATLAB)绘制三维曲线(plot3/plot)

本实验取材于中南大学《MATLAB和科学计算》
今天学习了三维曲线,还是比较正规操作,老师也讲的比较仔细,课下还需要仔细临摹
例子:绘制一条空间折线

>> plot3(x,y,z)
>> grid on
>> axis([0,3,1,3,0,2])
>>

在这里插入图片描述
例 绘制螺旋线
在这里插入图片描述

>> t=linspace(0,10*pi,200);
>> x=sin(t)+t.*cos(t);
>> y=cos(t)-t.*sin(t);
>> z=t;
>> subplot(1,2,1)
>> subplot(1,2,1)
>> hold off
>> hold off
>> subplot(1,2,1)
>> plot3(x,y,z)
>> grid on
>> subplot(1,2,2)
>> plot3(x(1:4:200),y(1:4:200),z(1:4:200))
>> grid on
>>

在这里插入图片描述
(2)plot函数参数的变化形式

  1. plot3(x,y,z)
  2. 参数x、y、z是同型矩阵
  3. 参数x、y、z中有向量,也有矩阵
    例子:在空间不同位置绘制三条正弦曲线
>> t=0:0.01:2*pi;
>> t=t';
>> x=[t,t,t,t,t];
>> y=[sin(t),sin(t)+1,sin(t)+2,sin(t)+3,sin(t)+4];
>> z=[t,t,t,t,t];
>> plot3(x,y,z)
>> subplot(1,1,1)
>> plot3(x,y,z)
>> grid on

在这里插入图片描述
(3)含多组输入参数的plot3函数

plot(x1,y1,z1,x2,y2,z2,.....,xn,yn,zn)

每一组x,y,z向量构成一组数据点的坐标,绘制一条曲线
例子:绘制三条不同长度的正弦曲线

>> t1=0:0.01:1.5*pi;
>> t2=0:0.01:2*pi;
>> t3=0:0.01:3*pi;
>>plot3(t1,sin(t1),t1,t2,sin(t2)+1,t2,t3,sin(t3)+2,t3)
>> grid on
>> title('三条不同长度的正弦曲线')
>> legend('t1','t2','t3')
>>

在这里插入图片描述
(4)含选项的plot3函数

  1. plot3(x,y,z,选项)
  2. 选项用于指定区曲线的线性、颜色和数据点标记
    绘制函数
>> t=0:pi/50:6*pi;
>> x=cos(t);
>> y=sin(t);
>> z=2*t;
>> plot3(x,y,z,'p')
>> xlabel('X'),ylabel('Y'),zlabel('Z');
>> grid on

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值