How to colaapse a table to reduce repeated rows?
이전 댓글 표시
Ho,
I have a table of 6 columns. Many rows are the same. I want to collapse the same rows into one. So I use this lines to create a new table:
vMarket = 'AB';
tb='Summer';
tp = 1;
mask=strcmpi(cTblSet.VM(:),vMarket) & strcmpi(cTblSet.TB(:),tb) & (corrTblSet.TimePeriod(:) == tp);
newtable = cTblSet(mask, :);
But the newtable has 0 rows, it should have 20 rows.
The 'TimePeriod' column is all numbers. If the mask is only
mask=strcmpi(cTblSet.VM(:),vMarket) & strcmpi(cTblSet.TB(:),tb)
Then newtable has the right number of rows.
Why? Why a column of numbers are not working properly here? How to fix this problem? Thanks,
Jennifer
댓글 수: 1
Stephen23
2015년 8월 27일
This time I formatted your code for you, but in future please do it yourself by selecting the code and clicking the {} Code button that you will find above the textbox.
답변 (3개)
the cyclist
2015년 8월 27일
0 개 추천
The simplest way to do what you want is probably to use the unique command, with the 'rows' option.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!