How to count the values in a column with different lower and upper bounds from excel?
Afficher commentaires plus anciens
Hi all,
I am trying to find solution for the following problem
Example:
D=xlsread('data.xlsx','sheet1')
a=D(:,2:2:6) % Col B: [1 2 3 4 5 6 7 8 9 10 11 12 18 20 21 22 28 29], Col D: [1 5 9 11 12 20 29], Col F: [7 9 15 17 19 21 22 28 29 30]
lb=a(:,9) % Lower bound values read from Col I: [1 10 20]
ub=a(:,11) % Upper bound values read from Col K: [10 20 30]
ColB must be read first and the count based on each of the lower and upper bound ranges must be given as an output, and the loop must then read the data in Column 4 to again give output based on the condition of different lower and upper bound ranges.
Solution:
Col B: [9 4 5]
Col D: [3 2 2]
Col F: [2 3 4]
What I tried is to get these values reading each column for different ranges seperately.
r1= sum(a(:,2)>=1 & a(:,2)<10)
r2=sum(a(:,2)>=10 & a(:,2)<20)
r3=sum(a(:,2)>=20 & a(:,2)<30)
Solution: [9 4 5]
did this again for Col D, and Col F (similar process in using Excel)
Highly appreciate for making this simple with a loop.
Kind Regards,
Jagan

Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Data Import from MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!