Data Streaming from updating .txt file
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I have a software that collect data from a hardware, these data are stored in text files and keep updeating, now I am doing some experiment and I want to use the real time data in those .txt files and import it into matlab, I want to be able to import the data every specific time lets say 1 minute, and then after impleminting some processes on the data I want to import more data from the point it stopped lastly. Is there a documintation specificlly for this purpose? could u please refere me to?
0 Kommentare
Antworten (1)
Amith
am 23 Aug. 2024
Hi Omilnoth,
I understand that you would like to import data from a text file. You can achieve this using the importdata function. For more details, you can refer to this MATLAB documentation: https://www.mathworks.com/help/matlab/ref/importdata.html#btk7vi1-2_1
To import data from a text file, perform a specific operation, and repeat this process, you can refer to the following code:
filename = 'yourfile.txt'; % Replace with your actual file name
while true
% Import data from the text file
data = importdata(filename);
% Open the file in write mode, which clears its contents
fid = fopen(filename, 'w');
% Close the file
fclose(fid);
% Display the imported data (optional) - here you can perform the operations you would
% like to do
disp(data);
% Pause for 10 seconds
pause(10);
end
This script will continuously import data from `yourfile.txt` every 10 seconds. It deletes the file's contents after reading and displays the previously read contents in the MATLAB command window. You can replace `disp(data)` with any processing or analysis you wish to perform on the imported data. By clearing the file's contents up to that point, new data can be populated and subsequently processed for further operations.
I hope this would help you achieve the desired result.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!