Plotting over a Range of Values
1 次查看(过去 30 天)
显示 更早的评论
I'm trying to plot orbital speed and period over a range of altitudes, but I keep getting the following error:
Error using /
Matrix dimensions must agree.
Error in aeroq25 (line 6)
orbital_speed = sqrt(mu_earth*((2/altitude)-(1/altitude))); %km/s
Does anyone have any tips? Here is my code for reference:
altitude = 150:1:1000;
mu_earth = 3.986*10^5; %km3/s2
orbital_speed = sqrt(mu_earth*((2/altitude)-(1/altitude))); %km/s
period = 2*pi*sqrt((altitude^3)/mu_earth); %second
plot(altitude, orbital_speed);
0 个评论
采纳的回答
Chunru
2021-10-19
Use the array operator .* ./ .^2 for arrays.
altitude = 150:1:1000;
mu_earth = 3.986*10^5; %km3/s2
orbital_speed = sqrt(mu_earth*((2./altitude)-(1./altitude))); %km/s
period = 2*pi*sqrt((altitude.^3)/mu_earth); %second
plot(altitude, orbital_speed);
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!