How can i store looped data from sensor in a table?
16 ビュー (過去 30 日間)
古いコメントを表示
Alexander
2025 年 2 月 25 日 21:42
In this code im reading sensor data in a loop for a specified ammount in a loop. I am trying to store the data in a table but can for the life of me figure out how to do that. here is what i have so far. Any help would be appriciated, or point me to domcumentation that will help. thank you in advance
while i < MaxDataLeng
i = i + 1;
temperature = readTemperature(bmp);
temp_f = ceil (temperature * (9/5)) +32;
pressure = readPressure(bmp);
Altitude = BalAltFunc (pressure, temp_f);
fprintf ('%d\n',i);
fprintf ('---------------------------------------------------------------------------------------------------\n');
fprintf ('temperature: %d F \n', temp_f);
fprintf ('pressure: %f0.1 hPa \n', pressure);
fprintf ('altitude: %d meters \n', Altitude);
fprintf ('---------------------------------------------------------------------------------------------------\n');
pause(Delay);
C = {'interval', 'temp', 'pressure', 'altitude'; i temp_f pressure Altitude;};
end
end
0 件のコメント
採用された回答
Walter Roberson
約5時間 前
編集済み: Walter Roberson
約5時間 前
Initialize
T = table('Size', [0 4], 'VariableTypes', repmat({'double'},1,4), 'VariableNames', {'interval', 'temp', 'pressure', 'altitude'});
Then in your loop,
C = {i temp_f pressure Altitude};
T(end+1,:) = C;
You will probably want to remove the fprintf() from inside the loop.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!