extract numbers form a column
Show older comments
I have a double collumn set of data, something like that:
Q= [0 15
0 18
0 12
1 12
2 15
0 17
0 12
2 7
0 12
0 11]
I need to get the mean values of ech array in column 2, where are zeros in column 1. Or at lest extract those aarays onto different variables, they need to be separated. Can anybody help me please?
Thank you
3 Comments
Sargondjani
on 17 Jan 2021
Edited: Sargondjani
on 17 Jan 2021
Try something like:
ind0 = Q(:,1) ==0%select the entries where Q(:,1) is 0
Sum_Q0 = mean(Q(ind0,2))%take the mean of the entries of Q(:,2) where ind0==1
This might not be fasted way, but its simple :-)
ShonyE
on 17 Jan 2021
dpb
on 17 Jan 2021
See below...
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!