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

1 view (last 30 days)
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);

Accepted Answer

Walter Roberson
Walter Roberson on 26 Sep 2015
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.
  7 Comments
c cl
c cl on 27 Dec 2015
Thanks again!Here is the code for 3D contour:
clc;clear;
figure;
[C3,H3]=contour3(peaks(30),10);
ra=1.2;
for n3=1:length(H3)
hh=get(H3(n3),'Zdata');
newhh=hh*ra;
set(H3(n3),'Zdata',newhh,...,
'edgecolor',[0 0 0],'linewidth',1.2);
end
grid off;
I can change the position of each contour line according to the "ra". Besides, it is also possible to change the color of each line as I want. Now I still use it in R2014a and the result is very good!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!