File Exchange

image thumbnail


version 1.2 (73.7 KB) by

Group a flat dataset into pivot table and unpivot it back

3 Ratings



View License

These two functions are meant to format a flat dataset into a pivot table and to unpivot it back.
They imitate the T_SQL pivot/unpivot commands or the pivoting functionalities of the spreadsheet softwares.

If you a have a large set of values which are described by two features (or more) this function allows you to group those values by those two features.

For example, you can sum to the total amount sold over the last 10 months by any of your employees or you can count the number of contracts signed by region and by salesmen and so on...

For detailed help and description see the published M-file or the help of the functions.

For examples see the attached snapshot.
Comments/suggestions/error reports are welcome.

Thanks to Jos (10584) for cell2float.


Comments and Ratings (4)

Ms. Mat


Oleg Komarov

Oleg Komarov (view profile)

Previous releases compatibility is not achieved at the moment. I'll update the submission asap.



unPivot: fixed column position in Out (the first was switched with the second)


Corrected syntax for compatibility; edited description; added link to the submission

MATLAB Release
MATLAB 7.9 (R2009b)

Inspired by: CELL2FLOAT

Inspired: mat2piv.m

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video