MATLAB:将两个数组转换为稀疏矩阵
我正在寻找将两个数组转换为稀疏矩阵的命令或技巧。这两个数组包含 x 值和 y 值,它们给出笛卡尔坐标系中的坐标。我想对坐标进行分组,如果该值位于 x 轴和 y 轴上的某个值之间。
% MATLAB
x_i = find(x > 0.1 & x < 0.9);
y_i = find(y > 0.4 & y < 0.8);
%Then I want to find indicies which are located in both x_i and y_i
这个小技巧有简单的方法吗?
I'm looking for an a command or trick to convert two arrays to a sparse matrix. The two arrays contain x-values and y-values, which gives a coordinate in the cartesian coordinate system. I want to group the coordinates, which if the value is between some value on the x-axes and the y-axes.
% MATLAB
x_i = find(x > 0.1 & x < 0.9);
y_i = find(y > 0.4 & y < 0.8);
%Then I want to find indicies which are located in both x_i and y_i
Is there an easy way to this little trick?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设
x
和y
具有相同的形状(如果它们是坐标,则它们应该具有相同的形状),您可以简单地编写如果您想要一种通用的方法来查找常见的数字对于两个列表,您可以使用相交
Assuming that
x
andy
have the same shape (which they should if they're coordinates), you can simply writeIf you want a general way to find numbers that are common to two lists, you can use intersect