Help requested for generating an example for this kind of 3D plot
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
Hi
Please see the figure attached. I have explored a lot but I have not been able to find options to generate a plot like the one shown. Any example (dummy data) would do perfectly for me. Thanks a lot

댓글 수: 0
답변 (2개)
  chicken vector
      
 2023년 4월 21일
        
      편집: chicken vector
      
 2023년 4월 21일
  
      You can use surf to generate 3D meshes and inpolygon as binary mask to customise the shape of the base grid.
% Number of grids:
nGrid = 50;
% Get [X, Y, Z] data for the plot:
[X,Y] = meshgrid(-1:1/nGrid:1, -1:1/nGrid:1);
Z = peaks(X,Y);
% Number of star corners:
nVertices = 5;
% Outer vertices:
theta = 2*pi*(1/nVertices:1/nVertices:1);
outerVertices = [cos(theta), sin(theta)];
% Inner vertices:
theta = theta + 2*pi/(nVertices*2);
innerVertices = [cos(theta), sin(theta)]/2;
% Compute mask indeces:
vertices = [outerVertices;innerVertices];
vertices = reshape(vertices(:),[],2);
pointsInsideStar = inpolygon(X, Y, vertices(:,1), vertices(:,2));
% Set Z values to NaN when outside the star:
Z(~pointsInsideStar) = NaN;
% Plot:
surf(X, Y, Z, 'AlphaData', ~isnan(Z), 'EdgeColor', 'k', 'FaceColor', [.5 .5 .5])
% Axes labels:
xlabel('x [\mum]')
ylabel('y [\mum]')
zlabel('Film thickness [\mum]')
Result:

댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


