Finding ranges 2to5, 5to10 and 10to20 out of large values in a large array.
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi Guys
I have a Question about finding different ranges e.g 2 to 5, 5 to 10 and 10 to 20, within a large array .
I have an array 'DOP' of dimension 1x86400 that contains values between 0 and 1.4804e+05. I wanted numbers between 0 to 20 within that array so this range found by a condition
if (DOP(j)<=20);
DOPj(j)=j;
end
eles
'check on another iteration'
within while loop. Here j is the time at which DOP<=20. So DOPj contains the times values at which DOP<=20 and 0s at times where there is no DOP<=20. So DOPj also has same dimension as DOP i.e. 1x86400.
Now I have a new array DOPj of same dimension but with values of times at which we have DOP<=20 and 0s at times where there is no values DOP<=20.
I discarded 0s in DOPj by
[i20 j20]=find(DOPj);
Now j20 has only times at which DOP<=20. Length(j20) gives 39961. That means out of 86400 values of DOP I have 39961 values that of DOP<=20.
Now I can find the indices of DOP at which I can have different ranges 2 to 5, 5 to 10 and 10 to 20 by
[i25 j25]=find(DOP(j20)>=2 & (DOP(j20)<=5));
[i510 j510]=find(DOP(j20)>=5 & (DOP(j20)<=10));
[i1020 j1020]=find(DOP(j20)>=10 & (DOP(j20)<=20));
length(j25) gives 18423
length(j510) gives 14442
length(j1020) gives 7096
and
length(j1020)+length(j510)+length(j25) gives 39961, which looks great.
But unfortunately max(DOP(j25)) gives 1.4593e+04 and min(DOP(j25)) gives 0, which is totally wrong as I need range 0 to 5.
similarly, max(DOP(j510)) gives 58.1935 and min(DOP(j510)) gives 0. Also max(DOP(j1020)) gives 159.3996 and min(DOP(j1020)) gives 0, which are all wrong,
Could someone help me out what I am doing wrong?
Thanks in advance.
Zohaib
0 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur Multibody Modeling dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!