Borrar filtros
Borrar filtros

Need help to solve with ncmlogo.m

12 visualizaciones (últimos 30 días)
Jessie Chen
Jessie Chen el 6 de Jul. de 2024 a las 8:32
Respondida: Steven Lord el 12 de Jul. de 2024 a las 15:51
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?

Respuesta aceptada

Steven Lord
Steven Lord el 12 de Jul. de 2024 a las 15:51
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.

Más respuestas (0)

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by