How to create a pivot table
Show older comments
I have a table
date person spendings
----------------------------------------
1/1/2020 John $100
1/1/2020 Mike $50
1/2/2020 John $75
1/3/2020 Mike $40
I want to create a pivot table
John Spendings Mike Spendings
----------------------------------------------------------------------------------
January 2020
February 2020
March 2020
Please advise.
Accepted Answer
More Answers (1)
Lola Davidson
on 17 Mar 2023
1 vote
As of R2023a, you can use the "pivot" function: https://www.mathworks.com/help/matlab/ref/pivot.html
Tout = pivot(Tin, Rows="date", RowsBinMethod="month", Columns="person", DataVariable="spendings");
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!