Odd behavior of unstack in Matlab2025b
Hello,
When calling the unstack function using @sum as the AggregationFunction for numerical values in 2025b, I’m getting the warning below and the empty groups get a zero (from summing into a 0-1 input)
Warning: When a group has no rows for a given value of the indicator variable, UNSTACK calls the supplied aggregation function with an input of size 0-by-1 instead of automatically filling the value.
Review the output to ensure desired result is obtained. This warning might be removed in a future release.
However the function documentation states the following:
Missing value of the appropriate data type, such as a NaN, NaT, missing string, or undefined categorical value.
Which is the behavior I used to get in previous Matlab versions (e.g. 2019b), would get NaNs from empty groups, and which I would have epxected to happend here since its what the documentation suggests.
Any thoughts on why this might be happening or if I can change the behavior so as to get NaNs instead of calling the aggregation function into a 0-1 input for the empty groups?Hello,
When calling the unstack function using @sum as the AggregationFunction for numerical values in 2025b, I’m getting the warning below and the empty groups get a zero (from summing into a 0-1 input)
Warning: When a group has no rows for a given value of the indicator variable, UNSTACK calls the supplied aggregation function with an input of size 0-by-1 instead of automatically filling the value.
Review the output to ensure desired result is obtained. This warning might be removed in a future release.
However the function documentation states the following:
Missing value of the appropriate data type, such as a NaN, NaT, missing string, or undefined categorical value.
Which is the behavior I used to get in previous Matlab versions (e.g. 2019b), would get NaNs from empty groups, and which I would have epxected to happend here since its what the documentation suggests.
Any thoughts on why this might be happening or if I can change the behavior so as to get NaNs instead of calling the aggregation function into a 0-1 input for the empty groups? Hello,
When calling the unstack function using @sum as the AggregationFunction for numerical values in 2025b, I’m getting the warning below and the empty groups get a zero (from summing into a 0-1 input)
Warning: When a group has no rows for a given value of the indicator variable, UNSTACK calls the supplied aggregation function with an input of size 0-by-1 instead of automatically filling the value.
Review the output to ensure desired result is obtained. This warning might be removed in a future release.
However the function documentation states the following:
Missing value of the appropriate data type, such as a NaN, NaT, missing string, or undefined categorical value.
Which is the behavior I used to get in previous Matlab versions (e.g. 2019b), would get NaNs from empty groups, and which I would have epxected to happend here since its what the documentation suggests.
Any thoughts on why this might be happening or if I can change the behavior so as to get NaNs instead of calling the aggregation function into a 0-1 input for the empty groups? unstack, 2025b MATLAB Answers — New Questions









