matlab标线,如何在matlab中以方位角画线?

你最好的办法是依靠一个内置的极性绘图功能做到这一点。我认为与您的需求最相似的是compass。它基本上绘制了一个箭头,从中心指向一个极坐标图上的一个点(以笛卡尔坐标定义)。

theta = deg2rad(130);

% Your speed in m/s

speed = 5;

hax = axes();

c = compass(hax, speed * cos(theta), speed * sin(theta));

% Change the view to orient the axes the way you've drawn

view([90 -90])

2c98a18930ff5fb6e3d8933ce2b852e3.png

然后为了改变轴承和速度,你只需再次与你的新的轴承/速来电compass功能。

new_theta = deg2rad(new_angle_degrees);

c = compass(hax, new_speed * cos(new_theta), new_speed * sin(new_theta));

其他极性绘图选项包括polar和polarplot其接受极坐标,但没有一个箭头。如果你不喜欢极坐标图,你可以在笛卡尔坐标轴上始终使用quiver(确保指定相同的坐标轴)。

编辑 根据您的反馈和请求,以下是距离行驶极坐标图的示例。

% Speed in m/s

speed = 5;

% Time in seconds

time = 1.5;

% Bearing in degrees

theta = 130;

hax = axes();

% Specify polar line from origin (0,0) to target position (bearing, distance)

hpolar = polar(hax, [0 deg2rad(theta)], [0 speed * time], '-o');

% Ensure the axis looks as you mentioned in your question

view([90 -90]);

84f407def3bbe333ad0240e252e78ae4.png

我们更新此情节与新的轴承,速度,时间,你会简单地调用polar再次指定轴。

hpolar = polar(hax, [0 theta], [0 speed], '-o');

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值