필터 지우기
필터 지우기

How to make this 3D plot?

조회 수: 1 (최근 30일)
Leonardus Risky
Leonardus Risky 2018년 7월 18일
답변: tarek hussein 2022년 10월 6일
Hello Everybody, can anyone help me how to get this plot if i have every variables in x, y, and z axis and i want to plot in 3D but i need my plot is rotating along Y axis and the plot result is like in the image. Thank You.

채택된 답변

Aquatris
Aquatris 2018년 7월 18일
You need the location of each node and the vibration amplitudes (assuming circular orbits) or magnitudes in each direction (assuming elliptical orbits). Then you need to create ellipses or circles at each node location. Here is the modified code where I assumed Y is the node locations, X and Z are the vibrations at their respective nodes.
X = [0 4 5 -2 0 2 4 1 4 2];
Y = [0 1 2 3 4 5 6 7 8 9];
Z = [0 2 1 -3 -2 -1 3 1 3 -1];
theta = 0:0.01:2*pi;
for i = 1:length(X)
Xv = X(i)*cos(theta);
Zv = Z(i)*sin(theta);
Yv = repelem(Y(i),length(theta));
plot3([0 0],[0 Y(end)],[0 0],'r-',Xv,Yv,Zv,'k-');
hold on;
end
axis([-10 10 -10 19 -10 10])
grid on
This is not an optimized code. Each iteration of for loop draws one of the ellipses. One can optimize it by converting the for loop into a simple matrix multiplication. You should play with the aestetics option to obtain what you actually want.
  댓글 수: 2
Leonardus Risky
Leonardus Risky 2018년 7월 18일
it can't run becasue this error: Undefined function 'repelem' for input arguments of type 'double'.
Error in plotmodes (line 9) Yv = repelem(Y(i),length(theta));
but what i want is to how i plot the 3D line in the 3D plot is make a elipse along with Y axis if Y is the nodal location and X,Z axis is the response displacement. Thank You for your response.
Aquatris
Aquatris 2018년 7월 18일
You might be using an older version where repelem function is not built-in. change that part to
Yv = Y(i)*ones(1,length(theta));
The image is the output of the code.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

tarek hussein
tarek hussein 2022년 10월 6일
how i can plot orbit of vibration of a rotating shaft with its center
x1=BD(1:10000,1 ) % the vibration vector readings in x direction
y1=BD(10000:15000,2) % the vibration vector readings in y direction
figure
p1= plot(x1,y1)
xlabel(' journal Disp in X direction');
ylabel('journal Disp in Y direction');
grid on

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by