Save the height to an array and increment the array counter for the duration of the flight.
myHeight=[];
i=0;
drone.takeoff;
while(some condition)
i=i+1;
myHeight(i)=readHeight(drone);
pause(some time);
end
drone.land;
MathWorks also supports the Ryze Tello EDU version in MATLAB. For the EDU versions, you can actually control multiple drones at once in a single MATLAB script. Ryze Tello Drone Support from MATLAB