`n=100;[Zf_S, Zf_L] = cellfun(@(B) bounds(B, 'all'), Zf);Zf_max = max(Zf_L);Zf_min = min(Zf_S);Zf_vals = linspace(Zf_min, Zf_max, n);[Df_S, Df_L] = cellfun(@(B) bounds(B, 'all'), Df);Df_max = max(Df_L);Df_min = min(Df_S);Df_vals = linspace(Df_min, Df_max, n);for i=1:1 ZZ = Zf{i}; DD = Df{i}; Zfr = discretize(ZZ, Zf_vals); Dfr = discretize(DD, Df_vals); zm = accumarray([Dfr Zfr], 1, [n n]); zmf{i}=zm;end surf(Zf_vals, Df_vals, zmf);`

This yields the error

Error using surf (line 71)

Z must be a matrix, not a scalar or vector.

Error in Analyze (line 236)

surf(Zf_vals, Df_vals, zmf);

What is the best way to add up all the zms so that I can plot all of the data in one histogram plot?

## Best Answer