MATLAB: Capture return of Sum() directly in to variables

sum

K=3×3 matrix when getting the sum it returns 1×3 matrix if try to capture it directly to variables given error
but same can be done with size() function

Best Answer

The size function has been implemented so it can return one output or multiple outputs. The sum function has not.
But even if sum had been implemented so it could return one output per element in the result of summing or one element per column, I recommend against trying to automatically create a dynamic number of variables with dynamic names. Read this Answer for a lengthy discussion about the problems that can occur when you do so.