Making an irregular cylinder using surface plotting
7 次查看(过去 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")
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!