Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Summing rows of one column based on another columns data

Asked by Sam Stuart on 7 May 2013

How can I sum one column based on the data in another column:

1    8
2    8
3    8
4    4
5    5
6    8
7    8
8    8
9    7

I have a column with numbers 1-8, and a column with just numbers in.

I want to add/sum the numbers in column 1 whenever the second column is less than 8. I need to only add the rows that are consecutive to each other.

Anyone got any ideas?

3 Comments

Sean de Wolski on 7 May 2013

This looks like it will be fun once you post a full example. Please provide all inputs and a sample output with an explanation of how you got it.

the cyclist on 7 May 2013

I agree with Sean that a bit more detail (and a small example) would help. I thought I knew what you meant, until you said "only add the rows that are consecutive to each other".

Try to put yourself in our place, trying to understand what you want to do, given only your description.

Jan Simon on 7 May 2013

I've formatted the numbers and suddenly 2 columns appear instead of onw row. I cannot imagine, why the OP did not care about the formatting. Perhaps he can explain, which part of the instructions is too hard to understand, such that TMW can improve it.

Sam Stuart

Products

No products are associated with this question.

0 Answers

Contact us