Log file Plot using Matlab in Realtime
显示 更早的评论
Software generates log files contains complex values, a 16-bit real integer and a 16-bit imaginary integer which is shown in text file starting from line 13.
Before line 13 general information which is not needed.
How can I get that data in to matlab and plot in real time?
I can not attach log file so I converted and attached it into *.txt file
回答(1 个)
Walter Roberson
2019-10-7
0 个投票
You will need to fopen() the file for reading.
Start an indefinite loop to read blocks
WIth the indefinite loop, start a second oop using fgetl() and looking for lines that start with 'Accum Len'. If the line does not start with that, loop back to fgetl(). If the line does start with it, then parse the line to get the number; that will be the number of samples to read.
Now use textscan() with appropriate format and delimiter ',' . Right after the format parameter, pass in the number of samples (e.g., 1016). cell2mat() the textscan results, and proceed to plot or store the information .
After that you loop back in the indefinite loop to read more blocks -- you would be back to the mode of skipping lines until you get to Accum Len.
3 个评论
TAPAN PATEL
2019-10-7
Walter Roberson
2019-10-7
You mention that you want to do this in "Real Time". Is it correct that some other program will be writing more data to the end of the file while the MATLAB program is running to plot the data? If so then there are complications around reaching the end of file; unless there is some kind of protocol to signal between the two processes, at any one time that the MATLAB routine goes to look at the file, the other routine might be in the middle of reading the file. If you are using MS Windows that potentially mandatory locking could cause problems too.
TAPAN PATEL
2019-10-8
类别
在 帮助中心 和 File Exchange 中查找有关 Scopes and Data Logging 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!