MATLAB: How to change the codes to adapt to the change of graphic handle changes in r2014b

graphic handler2014b

The following codes work well in r2014a. But it does not work in r2014b because the graphic handle has been changed. So would there be a quick way to change the codes? Any help would be highly appreciated.
[c,h]=contour3(peaks(30));
for i=1:length(h)
zz=get(h(i),'Zdata');
set(h(i), 'ZData', 0* ones(size(zz)));
end
view(3);

Best Answer

The replacement code for that is
contour(peaks(30));
view(3);
grid on
In the few releases before R2014b, contour() created a contourgroup and contour3() created patch objects (in older releases yet contour() produced patch as well). However, as long as you are not needing to distinguish between contour3() and contour() on the basis that the pre-R2014b contour3() cannot have filled contours turned on easily the way contour() can, or otherwise needing to mangle the patch properties, then contour() is effectively the same as contour3() except that contour() already has the z set at 0.
If you had happened to want to set the z to something other than 0, then I have no idea how to implement that from R2014b onward.