Need help to solve with ncmlogo.m
1 view (last 30 days)
Show older comments
Hello everyone! I am a freshman in MATLAB. When learning ncmlogo.m to picture a logo, I can not solve the problem of change z axis value of Isosurfaces to get them on different planes, but maintains the shape of the isosurface. The source code change the zdata:
L = rot90(membranetx(1,32,10,10),2);
% Filled contour plot with transparent lifted patches
b = (1/16:1/8:15/16)';
for k = 1:8
[c,h(k)] = contourf(L,[b(k) b(k)]);
m(k) = length(get(h(k),'xdata'));
set(h(k),'linewidth',2,'edgecolor','w', ...
'facealpha',.5,'zdata',4*k*ones(m(k),1))
end
But get the error:
Incorrect use of matlab.graphics.chart.primitive.Contour/setZDataImpl
Z must be at least a 2x2 matrix.
Error matlab.graphics.chart.primitive.Contour/set. ZData
Error untitled2 (line 25)
set(h(j), 'ZData', zdata);
Does the zdata have many meanings?
0 Comments
Accepted Answer
Steven Lord
on 12 Jul 2024
Let's look at the text of the error message.
Incorrect use of matlab.graphics.chart.primitive.Contour/setZDataImpl
Z must be at least a 2x2 matrix.
What are you using to set the Z data of the contour plot in your code?
set(h(k),'linewidth',2,'edgecolor','w', ...
'facealpha',.5,'zdata',4*k*ones(m(k),1))
What is the size of 4*k*ones(m(k), 1)? Does it have at least two rows and at least two columns? If m(k) is 2 or greater then it has at least two rows, but it's only going to have 1 column.
Rather than using length to create the value of m:
m(k) = length(get(h(k),'xdata'));
I think you'll want to use the size of the original Z data of the contour plot to create the new Z data for the contour plot instead.
Alternately, if I understand your description you might want to use either the contourslice function or (if you want to display a surface with the contour levels) maybe surfc.
0 Comments
More Answers (0)
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!