Making an irregular cylinder using surface plotting
15 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Star Strider
on 4 Dec 2023
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 Comments
Star Strider
on 4 Dec 2023
As always, my pleasure!
If I can help with the necessary tweaks, post back here to let me know.
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!