draw two 3D curve but can't hold them in one figure
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Aniruddha Katre
2014-8-20
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 个评论
Image Analyst
2014-8-20
You can "thank" him by officially "Accepting" his answer. It will give him reputation points.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!