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
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?
Guillaume
Guillaume 2015년 4월 28일
편집: Guillaume 2015년 4월 28일
"where the value of are", you're missing a word there (possibly "merged").
"between those of i and j", i and j being a range of values, what does that mean exactly? Between the max of i and the min of j?
Rami Ahmad
Rami Ahmad 2015년 4월 28일
I was trying to follow it from looking at between one set of values so I can simply write index = (merged(merged(:,3) > 3.02 & merged(:,3) < 3.020005)); which works fine. However I want to check between several values which is why I created i and j
Guillaume
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
Rami Ahmad 2015년 4월 28일
The idea of using the index approach is that if the value in merged is between i(1) and j(1) I will then have a logical array where I can then exclude the results that lie between these numbers. I don't need to know which ones meet the conditions for each value of i and j but the total logical array so I can say that I have checked between all of the respective values of i and j together and determined if any fall within those boundaries. Possibly indexing is not the best way to go about this, I'm not sure what is most suitable.
Jan
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
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에 대해 자세히 알아보기

태그

질문:

2015년 4월 28일

댓글:

Jan
2015년 4월 28일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by