1function C = lp_rows(M)
2% LP_ROWS Matrix to a cell array of rows, for jsonencode.
3%
4% jsonencode([1 2 3]) is [1,2,3], not [[1,2,3]], so a matrix with a single row
5% arrives on the JavaScript side with the wrong nesting. Encoding a cell array
6% of rows instead always gives an array of arrays.
7n = size(M, 1);
8C = cell(1, n);
9for i = 1:n
10 C{i} = M(i, :);
11end
12end