How can I change this code to make a header for each column like for instance accel X, accel Y, accel Z?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
WAN NOR NAZIRA MUSTAPA KAMAL
el 2 de Feb. de 2021
Respondida: Swastik Sarkar
el 18 de Jun. de 2025
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 comentarios
Respuestas (1)
Swastik Sarkar
el 18 de Jun. de 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 comentarios
Ver también
Categorías
Más información sobre Axes Appearance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!