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);

采纳的回答

Chunru
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 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by