How can I change this code to make a header for each column like for instance accel X, accel Y, accel Z?
2 views (last 30 days)
Show older comments
function [] = i2c_sensor()
a = arduino('COM3', 'UNO');
imu = mpu6050(a,'SampleRate',50,'SamplesPerRead',10,'ReadMode','Latest');
for i=1:10
accelReadings(i,:) = readAcceleration(imu);
display(accelReadings(i,:));
pause(1);
end
end

0 Comments
Answers (1)
Swastik Sarkar
on 18 Jun 2025
The appropriate data type you are looking for is the table in MATLAB. This data structure allows you to assign headers to each column. Below is an example, as referenced from the official documentation:
LastName = {'Sanchez';'Johnson';'Li';'Diaz';'Brown'};
Age = [38;43;38;40;49];
Smoker = logical([1;0;1;0;1]);
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80];
T = table(LastName,Age,Smoker,Height,Weight,BloodPressure)
For more detailed information on table, please refer to the official MATLAB documentation:
Hope this helps add header column !
0 Comments
See Also
Categories
Find more on Axes Appearance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!