How can i store looped data from sensor in a table?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alexander
el 25 de Feb. de 2025
Comentada: Alexander
el 25 de Feb. de 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 comentarios
Respuesta aceptada
Walter Roberson
el 25 de Feb. de 2025
Editada: Walter Roberson
el 25 de Feb. de 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.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!