some questions about how to read and write txt file on matlab

조회 수: 1 (최근 30일)
vx2008
vx2008 2014년 6월 7일
편집: dpb 2014년 6월 8일
I have create an txt file as below:
then I can read it into matlab by csvread/dlmread, which is ok.but when I change the file as below, it will be never read again:
1. So how shall I read the txt file as above into matlab normally?
2. how shall I add or delete some date, such as numbers 1,2,4 or charactors a,b,c and so on into the txt file?
3. image that an txt file was written by an procedure about 1 time 1 data per 0.1 seconds and the txt file would be written done (completed), then I will read this file at once to get the last data by matlab and do some computing for it. question: how shall I know the file is done or not by matlab?
thank you

채택된 답변

dpb
dpb 2014년 6월 7일
편집: dpb 2014년 6월 8일
1) When you switch to mixed character/numeric data, then csvread and friends are no longer suitable to use--they can't (and are documented to not) handle anything except regular all-numeric input. If you must make such changes, you'll need to use textscan that will return a cell array and you'll also have difficulty if the format of which field within the array changes form in reading the file as anything but fully text as the formatting will need to match. Looks like a very overhead-intensive way to try to do things.
2) See above; keep the whole thing as character or make a different storage structure of separate lists to handle the two if must have both types.
3) That's a tough one because of file buffering and all in the OS that you don't have direct control of. What's the other process; can it read input from standard input so you could dispatch with SYSTEM? Or, look at memmapfile and into using a flag variable.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by