How can i store looped data from sensor in a table?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Alexander
am 25 Feb. 2025
Kommentiert: Alexander
am 25 Feb. 2025
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 25 Feb. 2025
Bearbeitet: Walter Roberson
am 25 Feb. 2025
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.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!