Making an irregular cylinder using surface plotting
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Kyle Watkins
el 4 de Dic. de 2023
Comentada: Star Strider
el 4 de Dic. de 2023
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 comentarios
Respuesta aceptada
Star Strider
el 4 de Dic. de 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 comentarios
Star Strider
el 4 de Dic. de 2023
As always, my pleasure!
If I can help with the necessary tweaks, post back here to let me know.
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!