MATLAB: Using splitapply on a table to split a column with repeating rows

MATLABsplitapply

Hello, I'm using splitapply but cannot seem to solve the following where I have an initial table as follows but want the final table. Fin_year is categorical, Type is categorical, but Quantity and the resulting City_quantity and Rural_quantity are numeric. Notice the repeating year row values in the initial table.

Best Answer

See if the unstack function will do what you want.