How can i store looped data from sensor in a table?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Alexander
il 25 Feb 2025
Commentato: Alexander
il 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 Commenti
Risposta accettata
Walter Roberson
il 25 Feb 2025
Modificato: Walter Roberson
il 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.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!