生成正确的情节

4次观看(最近30天)
凯尔·布​​罗德(Kyle Broder)
我想使用Euler的方法绘制宫殿 - 纳迦电势中的星系轨道。生成的情节应该看起来像这样
但是,我一直保持直线。
我的代码由函数给出
Eulersystem_mnmodel()
parsec = 3.08*10^18;
R_1 = 8.5*1000.0*PARSEC;%这将我们的R值转换为CM。
Z_1 = 0.0;
theta_1 = 0.0;%Initial Value for Theta.
U_1 = 100.0*10^5;cm/sec的U初始值%
V = 156.972*10^5;CM/sec中径向速度的拟议值%
W_1 = 1;
GRAV = 6.6720*10^-8;%Universal gravitational constant
Amsun = 1.989*10^33;%提出的太阳角动量
AMG = 1.5D11*AMSUN;
gm = grav*amg;%注意这是恒定的
nsteps = 50000;%步骤数
deltat = 5.0*10^11;百分之秒的%
angmom = r_1*v;%The angular momentum
angmom2 = angmom^2.0;%The square of the angular momentum
E = -gm/r_1 + U_1*U_1/2 + angmom2/(2.0*r_1*r_1);系统的总能量百分比
时间= 0.0;
为了i = 1:nsteps
r_1 = r_1 + deltat*u_1;
U_1 = U_1 + deltat *(通用* r_1 / (r_1 ^ 2.0 + 1 +√z_1^2.0+1)^2.0)^1.5));
z_1 = z_1 + deltat*w_1;
w_1 = w_1+deltat*(gm*z_1*(1+sqrt(z_1^2.0+1)))/(sqrt(z_1^2.0+1)*(r_1^2.0+(1+sqrt(z_1^2.0+1))^2.0)^1.5));
theta_1 = theta_1 + deltat*(angmom/(r_1^2.0));
e = -gm/r_1+u_1/2.0+angmom2/(2.0*r_1*r_1);
ECC =(1.0 +(2.0*e*angmom2)/(gm^2.0))^0.5;
time1(i)=时间;
时间=时间+deltat;
r(i)= r_1;
z(i)= z_1;
结尾
数字()
情节(R,Z)
该代码运行良好,但是我得到了一条直线,而不是在链接图片中看到的螺旋。
1条评论
Image Analyst
Image Analyst 2016年8月27日
该链接不显示任何图像。请使用绿色和棕色框架图标将图像插入问题的正文中。
Also, don't use time as a variable. It's a built in function. And r and z are determined in the first 3 lines of your for loop, so why are those other lines calculating E, ecc, and theta_1 there if you don't use them???

登录发表评论。

答案(1)

Shruti Shivaramakrishnan
Shruti Shivaramakrishnan on 31 Aug 2016
发布的图似乎代表了一条线的网格,并且主要需要绘制多条线。我注意到该代码仅由单个绘图命令组成,该命令可能无法成功地绘制完整的网格。绘图时还需要考虑其他任何变体吗?

标签

社区寻宝

在Matlab Central中找到宝藏,发现社区如何为您提供帮助!

Start Hunting!