필터 지우기
필터 지우기

Making an irregular cylinder using surface plotting

조회 수: 12 (최근 30일)
Kyle Watkins
Kyle Watkins 2023년 12월 4일
댓글: Star Strider 2023년 12월 4일
I have this code to plot a surface using data collected from a scan of said surface. I am looking to plot this surface around a cylinder. I am unsure of where to start to get the surface into the shape of a cylinder. The Data table is a 60x12 table, Distance is a 60x1.
Data = table2array(CopyofPCADeRidder339);
figure(2)
surf(1:12,Distance,Data)
ax = gca;
ax.PlotBoxAspectRatio = [0.5 2 0.5];
set(gca,'YDir','reverse')
ylabel("Distance from Discharge (ft)")
xlabel("Kiln Position")
title("3D Total RunOut; Raw Data")
  댓글 수: 2
DGM
DGM 2023년 12월 4일
How exactly does this 2D data correspond to the surface of a cylinder?
Kyle Watkins
Kyle Watkins 2023년 12월 4일
The surface that was scanned was a rotating cylinder, this was then plotted as shown in the figure as a "flat" surface.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2023년 12월 4일
Here is one approach —
S = rand(60,12);
S = S.*((0:59).*exp(-0.1*(0:59))).';
figure
surf(S)
colormap(turbo)
axis('equal')
[X, Y, Z] = cylinder(1,size(S,1)-1);
% figure
% surf(X, Y, Z)
Xr = repmat(X(1,:), size(S,2), 1);
Yr = repmat(Y(1,:), size(S,2), 1);
zv = linspace(min(Z(:)), max(Z(:)), size(S,2));
Zr = (zv.*ones(size(S))).';
for k = 1:size(S,2)
Xc(k,:) = Xr(k,:).*(1+S(:,k)*0.1).';
Yc(k,:) = Yr(k,:).*(1+S(:,k)*0.1).';
end
figure
surfc(Xc,Yc,Zr)
colormap(turbo)
It may be possible to have the colormap code for the radius variations, however that is not in the documentation. It is not obviouos to me how to force it. The radius scaling is done in the loop that defines ‘Xc’ and ‘Yc’ so you will need to experiment with those to get the cylinder to look the way you want it to look. Use the view or rotate functions to change the viewpoint and orientation.
.
  댓글 수: 2
Kyle Watkins
Kyle Watkins 2023년 12월 4일
Thank you! I plan on playing around with it to fine tune the cylinder to use the surface I have plotted.
Star Strider
Star Strider 2023년 12월 4일
As always, my pleasure!
If I can help with the necessary tweaks, post back here to let me know.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by