contour3-With 3 dimensions input arguments

조회 수: 6 (최근 30일)
stelios loizidis
stelios loizidis 2022년 1월 10일
답변: Bjorn Gustavsson 2022년 1월 10일
Hello. I have the following: Α:24X24X24, B:24X24X24 and C:24X24X24
I want to make the contour3 plot
contour3(A,B,C)
but it shows me the following error: "Input arguments must have at most 2 dimensions". Is there a way to make a contour3 plot with three dimensions?

답변 (2개)

John D'Errico
John D'Errico 2022년 1월 10일
In order for a 3-d contour plot to make sense, you need to have some function, W(X,Y,Z), thuis a level surface, where you look for constant values of W as 3-d surfaces.
If all you have are A, B, and C, then a 3-d contour plot makes little sense.
If you actually have a 4th variable, you can use isosurface.
help isosurface
ISOSURFACE Isosurface extractor. FV = ISOSURFACE(X,Y,Z,V,ISOVALUE) computes isosurface geometry for data V at isosurface value ISOVALUE. Arrays (X,Y,Z) specify the points at which the data V is given. The struct FV contains the faces and vertices of the isosurface and can be passed directly to the PATCH command. FV = ISOSURFACE(V,ISOVALUE) assumes [X Y Z] = meshgrid(1:N, 1:M, 1:P) where [M,N,P]=SIZE(V). FV = ISOSURFACE(X,Y,Z,V) or FV = ISOSURFACE(V) selects an isosurface value automatically using the histogram of the data. FVC = ISOSURFACE(..., COLORS) interpolates the array COLORS onto the scalar field and returns the interpolated values in facevertexcdata. The size of the COLORS array must be the same as V. FV = ISOSURFACE(..., 'noshare') does not attempt to create shared vertices. This is faster, but produces a larger set of vertices. FV = ISOSURFACE(..., 'verbose') prints progress messages to the command window as the computation progresses. [F, V] = ISOSURFACE(...) or [F, V, C] = ISOSURFACE(...) returns the faces and vertices (and facevertexcdata) in separate arrays instead of a struct. ISOSURFACE(...) With no output arguments, a patch is created into the current axes with the computed faces and vertices. If no current axes exists, a new axes will be created with a 3-D view. Example 1: [x y z v] = flow; p = patch(isosurface(x, y, z, v, -3)); isonormals(x,y,z,v, p) p.FaceColor = 'red'; p.EdgeColor = 'none'; daspect([1 1 1]) view(3) camlight; lighting phong Example 2: [x y z v] = flow; q = z./x.*y.^3; p = patch(isosurface(x, y, z, q, -.08, v)); isonormals(x,y,z,q, p) p.FaceColor = 'interp'; p.EdgeColor = 'none'; daspect([1 1 1]); axis tight; colormap(prism(28)) camup([1 0 0 ]); campos([25 -55 5]) camlight; lighting phong See also ISONORMALS, ISOCAPS, SMOOTH3, SUBVOLUME, REDUCEVOLUME, REDUCEPATCH, SHRINKFACES. Documentation for isosurface doc isosurface
I'm not sure what you intend to see from contour3 given what you have.

Bjorn Gustavsson
Bjorn Gustavsson 2022년 1월 10일
Maybe you get what you need with the slice function, or perhaps isosurface. From my naive understanding we can draw iso-contours on a 2-D surface - and the extension of such iso-contours in 3-D becomes iso-surfaces. If you want one set of contours on each level in the z-direction you might get use of the attached function.
HTH

카테고리

Help CenterFile Exchange에서 Scalar Volume Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by