logical indexing between two varaibles
显示 更早的评论
I have these variables
i = i=3.02:0.00008:3.098;
j= 3.020005:0.00008:3.098005;
and a numerical array of 1000000x10. I want to determine in specific columns where the values of merged are between those of i and j, so in the first case I am trying to determine if the value is anything between 3.02 and 3.020005. I have tried some logical indexing where I used
index = (merged(merged(:,3) > i & merged(:,3) < j));
This however only seems to work if my numerical array is of the same dimensions as i and j which in this case would be 976x10. Any ideas how else to go about this to use logical indexing but with a numerical array of a larger size?
6 个评论
Adam
2015-4-28
If you want to test each value against the respective value of i and j then how do you expect the logic to behave if your matrix is larger than i and j?
Rami Ahmad
2015-4-28
Guillaume
2015-4-28
So do you want to compare merged to i(1) and j(1), then i(2) and j(2), and so on? What sort of output do you want? a logical array for each comparison?
Rami Ahmad
2015-4-28
Jan
2015-4-28
I still do not understand, what you want to achieve. Could create a tiny example with inputs and the wanted output?
回答(1 个)
pfb
2015-4-28
0 个投票
I'm not sure I understand your problem. It looks like some sort of binning problem.
You could try using "histc" on the columns of your matrix, using i or j (or a suitable combination thereof) to define the edges.
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!