draw two 3D curve but can't hold them in one figure

1 visualización (últimos 30 días)
Gary
Gary el 20 de Ag. de 2014
Comentada: Image Analyst el 20 de Ag. de 2014
the first curve is a solution of a differential equation
function dy=eq3(t,y)
dy=zeros(3,1);
dy(1)=-680*(y(1)-100000)/sqrt((y(1)-100000)^2+(y(2)-340*t)^2+(y(3)-10000)^2);
dy(2)=-680*(y(2)-340*t)/sqrt((y(1)-100000)^2+(y(2)-340*t)^2+(y(3)-10000)^2);
dy(3)=-680*(y(3)-10000)/sqrt((y(1)-100000)^2+(y(2)-340*t)^2+(y(3)-10000)^2);
end
and the second one is a line in a 3Dspace
[t,y]=ode45('eq3',[0:0.01:202],[0,0,0]);
plot3(y(:,1),y(:,2),y(:,3))
grid on
hold on
T=0:0.5:200;
X=100000;
Y=340*T;
Z=10000;
plot3(X,Y,Z,'r')
xlabel('x轴')
ylabel('y轴')
zlabel('z轴')
but they don't show up together

Respuestas (1)

Aniruddha Katre
Aniruddha Katre el 20 de Ag. de 2014
The reason why the second plot does not show up is because the variables "X" and "Z" are both scalars while "Y" is a vector. You can just convert "X" and "Z" to vectors of the same dimensions as "Y" and the plot should work. Assuming you want to keep "X" and "Z" constant, you can convert them to vectors in the following manner:
X=100000*ones(length(T),1);
Z=10000*ones(length(T),1);
  2 comentarios
Gary
Gary el 20 de Ag. de 2014
thx a lot
Image Analyst
Image Analyst el 20 de Ag. de 2014
You can "thank" him by officially "Accepting" his answer. It will give him reputation points.

Iniciar sesión para comentar.

Categorías

Más información sobre Scatter Plots 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