MATLAB Vectors and Sensor Data · Study
English translation
Topics covered
Combine time, height, and battery records into an array, then select and inspect the intervals and conditions you need.
Define row and column meanings
Using one row per time and one column per measurement lets you read values from the same time together. MATLAB indexing starts at 1; A(row,column) selects an element. A(:,2) selects the second column across all rows.
Select records using conditions
To find times when height is at least .5 m, create a logical array and select the time and battery values from the same rows. Preserve the original time correspondence after selection.
Connect to Onramp
Try Vectors and Matrices, Array Indexing and Modification, and Logical Arrays, then apply them to the measurement records below.
Worked example
Synthetic records: seconds, height [0,.4,.9,.7,.1] m, battery [92,91,90,89,88]%.
t=(0:4)';height_m=[0;.4;.9;.7;.1];battery_pct=[92;91;90;89;88];
measurements=[t,height_m,battery_pct];
selected=height_m>=.5;
disp(measurements(selected,:));
assert(isequal(size(measurements),[5,3]));
assert(isequal(t(selected),[2;3]));
plot(t,height_m,'o-');xlabel('Time [s]');ylabel('Height [m]');grid on;
Example results
The rows at 2 and 3 seconds satisfy the condition, and the full array has size 5×3.