Making an irregular cylinder using surface plotting
조회 수: 12 (최근 30일)
이전 댓글 표시
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")![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1560124/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1560124/image.jpeg)
댓글 수: 2
채택된 답변
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
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 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!