Plotting over a Range of Values

1 回表示 (過去 30 日間)
Ryan McPherson
Ryan McPherson 2021 年 10 月 19 日
コメント済み: Ryan McPherson 2021 年 10 月 19 日
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);
  1 件のコメント
Ryan McPherson
Ryan McPherson 2021 年 10 月 19 日
Awesome, thanks so much.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by