matlab - 如何在平面上表示网格圆?

标签 matlab plot

我的想法是使用颜色在极坐标(网格)中划分的平面圆中表示温度,因为绘图轴仅显示几何尺寸。

这就是我目前所拥有的。

[R,THETA] = meshgrid(linspace(0,r,nr),linspace(0,theta,ntheta)*(pi/180));
[X,Y] = pol2cart(THETA,R);    
contourf(X,Y,T,10);

enter image description here

这里的主要问题是那条糟糕的线和缺乏 theta 网格。

enter image description here

这就是我正在寻找的那种网格,但位于单个平面内。

代码:

r = 0.05; % Radius (m)
dr = 0.0025; % Element Size R (m)
nr = r/dr+1; % Number of Elements R
rc = (nr-1)/2+1; % Central Element R

theta = 360; % Degrees (°)
dtheta = 5; % Elezement Size Theta (°)
ntheta = theta/dtheta+1; % Number of Elements Theta

[R,THETA] = meshgrid(linspace(0,r,nr),linspace(0,theta,ntheta)*(pi/180));

[X,Y] = pol2cart(THETA,R);

T1 = 10;
T2 = 50;

dT = T2-T1; % dTemperature

for i = 1:73
    T(i,:) = T1:dT/(nr-1):T2; % Temperatura Distribution
    %T(i,:) = T(i,:) * i*0.5;
end

contourf(X,Y,T,10);

提前谢谢您。

最佳答案

不确定在这里使用网格是最简单的。 为什么不直接绘制线条,类似于 MATLAB 内置 polar() 中的操作:

N_half = 12;
th = (1 : N_half) * 2 * pi / (2 * N_half);
cst = cos(th);
snt = sin(th);
cs = [-cst; cst];
sn = [-snt; snt];
line(r * cs, r * sn, 'Color', 'k');
axis 'square'

给出

enter image description here

其中 N_half 修改您正在绘制的线数。

关于matlab - 如何在平面上表示网格圆?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33918598/

相关文章:

matlab - 如何使用 Matlab 通过最近邻插值法旋转图像

matlab - 具有 3d 条形和不同条形颜色的双变量直方图

python - 如何使用 mplfinance 在绘图中的其他线条上方显示蜡烛?

python - 如何在不同的图像上绘制给定的坐标?

r - ggplot 辅助 y 轴使用 sec_axis 显示 z 分数

Python - 在某些点绘制速度和加速度矢量

matlab - 如何在 MATLAB 中向量化这些 while 和嵌套 for 循环?

excel - 通过 Matlab 在 Excel 中插入图像

c - mex 文件 : compilation fails with with "//" comment; but compiles fine when used "/* */"

r - 如何更改 R 中 ctree 对象的绘图背景?