What does it mean to Initialize variables?

조회 수: 19 (최근 30일)
and5314
and5314 2015년 10월 1일
답변: Walter Roberson 2015년 10월 1일
If a stationary ball is released at a height h_0 above the surface of the Earth with a vertical velocity〖 v〗_0, the position and velocity of the ball as a function of time will be given by the equations:
h(t)= 1/2 gt^2 + v_0 t + h_0
v(t)= gt + v_0
where g is the acceleration due to gravity (-9.81 m/s^2), h is the height above the surface of the Earth (assuming no air friction), and v is the vertical component of velocity. Create variables for this problem
Initialize g, v_0= 1 m/s , and h_0=2 m
Initialize t to 1 second

답변 (2개)

Walter Roberson
Walter Roberson 2015년 10월 1일
Initialize means to assign them a value for the first time. You might change their values afterwards or you might not.
For example,
total = x;
if y > 5
total = total + y;
end
Here we could only have added y to total once we had already assigned a value to total. If the code had instead been
if y > 5
total = total + y;
end
then it would have failed because total did not exist yet.

Star Strider
Star Strider 2015년 10월 1일
Initialised variables are the values of the variables at the beginning of the simulation, and the values of the constants in it.

카테고리

Help CenterFile Exchange에서 Geometric Geodesy에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by