我正在寻找一个命令或技巧来将两个数组转换为稀疏矩阵。这两个数组包含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这个小把戏有没有简单的方法?
发布于 2010-04-28 04:45:00
假设x和y具有相同的形状(如果它们是坐标,则它们应该具有相同的形状),您可以简单地编写
commonIndices = find(x > 0.1 & x < 0.9 & y > 0.4 & y < 0.8);如果您需要一种通用的方法来查找两个列表共有的数字,则可以使用intersect
commonEntries = intersect(x_i,y_i);https://stackoverflow.com/questions/2724869
复制相似问题