Command similar to SumIf in Excel

2 views (last 30 days)
Alex
Alex on 23 May 2013
I have never done any programming, so keep that in mind when/if you answer.
I have a .csv file with 36 rows and 4 columns. It would look like this:
1 7 9 0
2 7 11 0
3 9 11 1
4 8 10 0
5 8 11 1
6 7 10 1
7 7 11 1
8 9 11 0
etc. down to 36 rows.
The first column is not really important. I want to end up with 6 sums for the 6 possible combinations of column 2 and 3. So if column 2 = 7 and column 3 = 9 that's the first sum, if column 2 = 8 and column 3 = 10 that's the second sum. If column 2 = 9 and column 3 = 11 that's the third sum, etc.....
the possible combinations are 7 and 9, 8 and 10, 9 and 11, 7 and 10, 7 and 11, and 8 and 11.
Basically, I want know how many they got correct in each combination of column 2 and 3. (in column 4, 1 = correct, 0 = incorrect)
I know there should be a simple enough way to do this, I can do it in excel in 10 seconds, but my supervisor wants me to write a program and I've been googling all day and everything is over my head. I know how to read in the file, but that's it. If you could explain how to do it rather than just give me some code, that would really help. I want to be able to figure these things out on my own, but I'm struggling.
  1 Comment
bym
bym on 23 May 2013
do you need to distinguish between 8 & 10 and 7 & 11 (both sums are 18) Also, what would your sumif formula look like in excel?...I am having trouble grasping what you are trying to do

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!