sum column based on match in another column
古いコメントを表示
Hello, I have a 2D array of data that is imported from Excel. The data is in the following format:
Data=[Date Shift Unit Code UpOn UpOff Down]
I have already sorted the data so that it is in date sequential order. But I have 0,1 or 2 entries for each date (using matlab's serial date format), Shift can be either a 1 or a 2. I need to sum the UpOff column for each date.
I would like to use a non-looping sort to generate this sum, something along the lines of:
DataSum = Data(Data(:,3)==1 & Data(:,2)==2,6) + Data(Data(:,3)==1 & Data(:,2)==1,6)
But the data may or may not have multiple entries so this format doesn't always generate matrices with the same number of rows for each side the summation. Is there another way that I can do this without resorting to using a loop and a test for each?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Shifting and Sorting Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!