Basicly, I draw a cylinder in my code, but I know it's not what I want. That cylinder doesn't use the experiment data, so it can not move or tilt. Somebody gave me a hint, which is mesh the upper circle and lower circle just using one mesh command, and transpose the mesh data to draw the cylinder part. But I think I don't really get it. So I hope somebody can help me!
Cylinder animation
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,I have a question about how to mesh a circular column based on experiment data. Now I can mesh the upper circle and lower circle, but I don't know how to mesh the cylinder part. Anybody can help? Here is my code:
clear;
data = load('F:\Experimental Data\110915\0909_01hz_alpha_01.txt');
u = size(data(9,:));
r0 = 500;
m = 10000;
for i=2000:10:m;
act1 = data(9,i)*4.5e-3;
act2 = data(10,i)*4.5e-3;
act3 = data(11,i)*4.5e-3;
P0 = [0 315 act1];
P1 = [272.8 -157.5 act2];
P2 = [-272.8 -157.5 act3];
O = [1/3*(P0(1) + P1(1) + P2(1)) 1/3*(P0(2) + P1(2) + P2(2)) 1/3*(P0(3) + P1(3) + P2(3))];
%set the vector
b = 1/2*[(P1-P0)+(P2-P0)];
c = P2-P1;
t = linspace(0,2*pi,36);
r = linspace(0,r0,30);
[T,R] = meshgrid(t,r);
%set unit vector
b = b/norm(b); c = c/norm(c);
n = cross(b,c);
%draw upper disk
X = O(1) + R.*cos(T)*b(1) + R.*sin(T)*c(1);
Y = O(2) + R.*cos(T)*b(2) + R.*sin(T)*c(2);
Z1 = O(3) + R.*cos(T)*b(3) + R.*sin(T)*c(3);
mesh(X,Y,Z1);
hold on;
%draw lower disk
Z2 = Z1 + 0.01;
mesh(X,Y,Z2);
hold on;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%draw cylinder
theta=linspace(0,2*pi,36);
x=500*sin(theta);
y=500*cos(theta);
z=linspace(0,0.01,36);
xx=meshgrid(x);
yy=meshgrid(y);
zz=[meshgrid(z)+O(3)]';
h=mesh(xx,yy,zz);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hold off;
axis([-500 500 -500 500 -0.05 0.05]);
getframe;
title('Cylinder Movement Animation','FontSize',20);
xlabel('x [mm]');
ylabel('y [mm]');
zlabel('z [mm]');
end
Anybody can modify "draw cylinder" part of my code, just using one mesh command and transpose matrix. Thanks!
0 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!