How can I change this code to make a header for each column like for instance accel X, accel Y, accel Z?
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Swastik Sarkar
2025 年 6 月 18 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Axes Appearance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!