Borrar filtros
Borrar filtros

How can I plot staked cylinders?

3 visualizaciones (últimos 30 días)
alegio20
alegio20 el 11 de Feb. de 2021
Respondida: Star Strider el 11 de Feb. de 2021
I have a matrix in which the number of rows are timesteps, the number of columns is the number of cylinders and the values are the diametes of the cylinders for each timesteps. Cylinders have all the same heigh fixed.
What I need, and I can't figured out how to do it, is for each time step to plot the stacked cylinders with correct diameters (and then create a video of the evolution of this "storey-cake", but I can handle this part).
I attach part of the code to generate the matrix of the diameters.
Qt = [0 617 2469 5555 9876 15432 22222 30246 39506 50000 50000 44444 38888 33333 27777 22222 16666 11111 5555 0]
hf = -1.02*5+0.0148*(Qt*1000).^(0.4); % Total Height of the "storey-cake"
hf = round(hf,1);
hcil = 0.1; % Height of every storey
A = zeros(length(hf),round(max(hf)/hcil)); % Matrix of diameters
zvirt = -1.02*5+0.00524*(Qt*1000).^(0.4);
for i = 1:length(hf)
n = hf(i)/hcil;
for j = 1:n
A(i,j) = 5*(1-j*hcil/hf(i));
end
end

Respuesta aceptada

Star Strider
Star Strider el 11 de Feb. de 2021
I cannot interpret much of your code, so I created my own version to plot the cylinders. You will need to adapt it to what you want to do, specifically with the cylinder radii, since I cannot figure out how that is supposed to work.
The Code —
cylfcn = @(r) r*[cos(linspace(0,2*pi)); sin(linspace(0,2*pi))];
figure
hold on
for k = 1:numel(Qt)
cyl = cylfcn(Qt(k)*1E-3); % Define Radius As ‘Qt(k)/1000’
hs = surf([1;1]*cyl(1,:), [1;1]*cyl(2,:), ([0;1]*hcil)+ones(size(cyl))+hcil*(k-1)); % Plot Cylinders
hs.EdgeColor = 'none'; % Turn Off Edges
hf1 = fill3(cyl(1,:), cyl(2,:), ones(1,size(cyl,2))+hcil*(k-1), 'g'); % Colour Cylinder Lower Surfaces Green
hf2 = fill3(cyl(1,:), cyl(2,:), ones(1,size(cyl,2))+hcil*(k), 'r'); % Colour Cylinder Upper Surfaces Red
% hf1.EdgeColor = 'none'; % Turn Off Edges
% hf2.EdgeColor = 'none'; % Turn Off Edges
end
hold off
view(30,30)
grid on
% axis('equal')
xlabel('X')
ylabel('Y')
zlabel('Z')
The Plot —
Each cylinder is ‘hcil’ units in height. Note that the radii equal to 0 will not plot.
I also demonstrated how to change the properties of the different parts of the plot, so you can customise them so they appear as you want them to appear.
.

Más respuestas (0)

Categorías

Más información sobre Visual Exploration en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by