Fixed in 2022a
maxrows = 1; r = 1; a = 1; c = 1; ii = false;
D = zeros(3,3,maxrows) % D is a double
D = 3×3
0 0 0
0 0 0
0 0 0
D(sub2ind([3,3,maxrows],a(ii),a(ii),r(ii))) = c(ii)
D = 3×3
0 0 0
0 0 0
0 0 0
D = zeros(3,3,maxrows,'sym') % now D is a sym
D =
D(sub2ind([3,3,maxrows],a(ii),a(ii),r(ii))) = c(ii)
D =