How to count the number of point and know their coordinates in a specified area from a scatter plot
2 次查看(过去 30 天)
显示 更早的评论
Hi all,
So, how to o count the number of point and know their coordinates in the specified area (the red area) from the scatter plot? I imported my array from excel, and this is my code below so far....
clf
clear all
clc
load ax
load ay
scatter(ax,ay);
xlabel('xlabel');
ylabel('ylabel');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/247220/image.png)
0 个评论
回答(2 个)
Stijn Haenen
2019-11-7
Hi,
This can be done with:
bx=ax(abs(ay-1.5)<0.2); by=ay(abs(ay-1.5)<0.2);
num_b=numel(bx);
Stijn Haenen
2019-11-7
Sure,
Lets start with a simple example:
x=1:10;
If you want to make an array with all the vallues of x that are for example larger than 5 you can use:
array=x(x>5); --> array = 6,7,8,9,10.
In your example you want all the point that with a y-coordinate between 1.3 and 1.7, in other words around 1.5 +-0.2.
Translating this to my simple example with x=1:10 where the output should be for example between 4 and 8 requires:
output=x(abs(x-6)<=2);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!