映射点集,其值表示半径为R的圆的半径

问题描述 投票:0回答:1

我有一组代表半径的数据点。我的阈值半径是R.如果我的数据点的半径<R或半径> R,我想用Matlab直观地显示它。

我已经成功地绘制了圆(使用圆的方程),但我的数据点被绘制在圆外,即使它们的值小于R.我认为我没有正确映射数据点。

我正在做以下事情:

%% Circle %%
% Radius = 1;
tx = linspace(-1,1,100);  %% X-data
ty = sqrt(1-tx.^2);      %% Y-data
ty2 = -ty;                %% (-)Y-data
%% Data Points %%
list_radius =[0.5870 0.2077 0.3012 0.4709 1.1524 6.7545 1.5581 1.8074];
%% PLOT %%
plot(tx,ty,':r',tx,ty2,':r')
hold on 
plot(list_radius)
hold off

我期待在圆圈内看到list_radius <1的点和圆圈外的list_radius> 1的点。谢谢你的帮助!

matlab matlab-figure
1个回答
0
投票

我建议你绘制圆圈,生成xy点为一个圆圈

x = R·cos(θ)

y = R·sin(Θ)

where Theta is a vector from 0 to 2*pi and R is your desired radius. Using this equation you don't have to generate a vector ty2 and you can plot your circle with one plot command.
R = 1;
theta = linspace(0,2*pi,1000);

tx = R*cos(theta);
ty = R*sin(theta);

list_radius =[0.5870 0.2077 0.3012 0.4709 1.1524 6.7545 1.5581 1.8074];

plot(tx,ty,':r');
hold on;
plot(list_radius,zeros(1,numel(list_radius)),'*');
axis equal

有了这个片段,我假设你的list_radius点位于x轴上。

© www.soinside.com 2019 - 2024. All rights reserved.