1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > MATLAB 太阳系九大行星运行(天文物理)天体仿真(一)

MATLAB 太阳系九大行星运行(天文物理)天体仿真(一)

时间:2023-11-01 04:33:38

相关推荐

MATLAB 太阳系九大行星运行(天文物理)天体仿真(一)

MATLAB 太阳系九大行星运行仿真,代码如下(没有依据实际的速度,大小,和相对位置,请自行搜集资料和调整):(代码有问题请留言,代码来源百度知道并稍加修改)

CODE BEGIN:

clear;clc;t=linspace(0,2*pi);;hold on;[x,y,z]=sphere;k=0; view(3); axis equal;axis([-90 90 -90 90 -80 80]); title('Nine planets in the solar system')theta=[pi/2.3 pi/3 pi/4 pi/6 pi/7];r=[15 2 35 65 85];w=[1 12 2 4 8];for m = 1:2for j=tk=k+1;cla;surf(5*x,5*y,5*z,'AmbientStrength',1);shading interpi=1;T=[sin(theta(i)),0,cos(theta(i));0,1,0;-cos(theta(i)) 0 sin(theta(i))];O=r(i)*T*[cos(t);sin(t);zeros(1,100)];o=r(i)*T*[cos(j*w(i));sin(j*w(i));0];plot3(O(1,:),O(2,:),O(3,:),':');surf(x+o(1),y+o(2),z+o(3),'FaceLighting','phong','AmbientStrength',.5);i=2;T=[sin(theta(i)),0,cos(theta(i));0,1,0;-cos(theta(i)) 0 sin(theta(i))];O=repmat(o,1,100)+r(i)*T*[cos(t);sin(t);zeros(1,100)];o=o+r(i)*T*[cos(j*w(i));sin(j*w(i));0];surf(x/i+o(1),y/i+o(2),z/i+o(3),'FaceLighting','phong','AmbientStrength',.5);plot3(O(1,:),O(2,:),O(3,:),':');shading interp;light('position',[0 0 0],'style','local');i=3;T=[sin(theta(i)),0,cos(theta(i));0,1,0;-cos(theta(i)) 0 sin(theta(i))];O=r(i)*T*[cos(t);sin(t);zeros(1,100)];o=r(i)*T*[cos(j*w(i));sin(j*w(i));0];plot3(O(1,:),O(2,:),O(3,:),':');surf(x+o(1),y+o(2),z+o(3),'FaceLighting','phong','AmbientStrength',.5);i=4;T=[sin(theta(i)),0,cos(theta(i));0,1,0;-cos(theta(i)) 0 sin(theta(i))];O=r(i)*T*[cos(t);sin(t);zeros(1,100)];o=r(i)*T*[cos(j*w(i));sin(j*w(i));0];plot3(O(1,:),O(2,:),O(3,:),':');surf(x+o(1),y+o(2),z+o(3),'FaceLighting','phong','AmbientStrength',.5);i=5;T=[sin(theta(i)),0,cos(theta(i));0,1,0;-cos(theta(i)) 0 sin(theta(i))];O=r(i)*T*[cos(t);sin(t);zeros(1,100)];o=r(i)*T*[cos(j*w(i));sin(j*w(i));0];plot3(O(1,:),O(2,:),O(3,:),':');surf(x+o(1),y+o(2),z+o(3),'FaceLighting','phong','AmbientStrength',.5);drawnowendend

CODE END

仿真效果1如图:

仿真效果2如图:

仿真效果3如图:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。