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

추가 답변 (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