pivottable

버전 1.0.0.0 (2.44 KB) 작성자: Zhiqiang Zhang
PIVOTTABLE Groups a matrix into a pivot table, is flexible as in Excel
다운로드 수: 3.4K
업데이트 날짜: 2011/2/27

라이선스 보기

out = pivottable(inMatrix, pivotRow, pivotColumn, valueColumn, valueFun) group
the input matrix "inMatrix" into a pivottable similar with Excel. Anyone
who are familiar with the pivottable in Excel will not have difficulties
with this function.

How the pivottables created are shown in following examples:
let
inMatrix = {
'2009', 'Mon', 12, 31;
'2009', 'Wed', 11, 34;
'2009', 'Fri', 1, 4;
'2009', 'Mon', 3, 4;
'2009', 'Wed', 9, 6;
'2009', 'Fri', 1, 4;
'2010', 'Mon', 18, 15;
'2010', 'Wed', 11, 21;
'2010', 'Wed', 1, 4;
};
then
pivottable(inMatrix, 1, 2, 3, @sum) output a cell
[] 'Fri' 'Mon' 'Wed'
'2009' [ 2] [ 15] [ 20]
'2010' [] [ 18] [ 12]
pivottable(inMatrix, [1 2], [], 3, @sum) output a cell
'2009' 'Fri' [ 2]
'2009' 'Mon' [15]
'2009' 'Wed' [20]
'2010' 'Mon' [18]
'2010' 'Wed' [12]
pivottable(inMatrix, [], 2, 3, @sum) output a cell
'Fri' 'Mon' 'Wed'
[ 2] [ 33] [ 32]
pivottable(inMatrix, 1, 2, [3 4], {@sum, @(x)(numel(x))})
[] 'Fri' 'Fri' 'Mon' 'Mon' 'Wed' 'Wed'
'2009' [ 2] [ 2] [ 15] [ 2] [ 20] [ 2]
'2010' [] [] [ 18] [ 1] [ 12] [ 2]

author: zhang@zhiqiang.org, http://zhiqiang.org/blog/it/pivottable-in-matlab.html
version: 2011-02-28 ver 1

인용 양식

Zhiqiang Zhang (2024). pivottable (https://www.mathworks.com/matlabcentral/fileexchange/30547-pivottable), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2010b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0