matlab - 在 MATLAB 中用复数绘制圆
问题描述
我所做的是以下内容:
x = [1 2 3];
y = [2 2 4];
radius = [1 1.2 2.2];
theta = [-pi 0 pi];
figure;
scatter(x,y,radius)
如何在绘图中添加角度 theta 以表示z = radius.*exp(1j*theta)
每个空间坐标处的复数?
解决方案
从技术上讲,如果 x 和 y 轴等比例缩放,这些只是圆圈。那是因为scatter
总是绘制圆圈,独立于比例(如果你不均匀地放大,它们仍然是圆圈。+你的线有问题,它应该指示角度......
您可以通过绘制圆圈来解决这两个问题:
function plotCirc(x,y,r,theta)
% calculate "points" where you want to draw approximate a circle
ang = 0:0.01:2*pi+.01;
xp = r*cos(ang);
yp = r*sin(ang);
% calculate start and end point to indicate the angle (starting at math=0, i.e. right, horizontal)
xt = x + [0 r*sin(theta)];
yt = y + [0 r*cos(theta)];
% plot with color: b-blue
plot(x+xp,y+yp,'b', xt,yt,'b');
end
有了这个小函数,你可以调用它来绘制任意数量的圆圈
x = [1 2 3];
y = [2 2 4];
radius = [1 1.2 2.2];
theta = [-pi 0 pi];
figure
hold on
for i = 1:length(x)
plotCirc(x(i),y(i),radius(i),theta(i))
end
推荐阅读
- swift - SwiftUI:是否存在修饰符来突出显示 Text() 视图的子字符串?
- bison - 可重入 Bison 解析器的参数未正确反映为 yyerror 的参数
- c# - 获得在 .Net Framework Console 应用程序中工作的安全 .Net Core 代码
- ios - Swift 在递归函数中没有返回正确的值
- c# - ASP.NET 播放视频,开头没有整个字节 []
- c++ - 使用完美转发的衰减
- reactjs - KeyboardAvoidingView 在标签导航中不起作用
- haskell - 两侧部分转换的光学元件
- python - 如何绘制 HSV 和 CIELAB 值的 3D 直方图?
- pandas - 为什么有给,名称'pd'未定义错误?