Prev: Dealing with a blank datenum result?
Next: Difference Mean Opinion Score (DMOS) for image/video/Voice Quality?
From: Khanh on 8 Aug 2010 21:50 I have a number of txt with similar format. I want to create a matlab function that can automatically call out a value for a specific name. For example, my txt file(mydata.txt) as followed dummy line 1 dummy line 2 ..... A=1 B=2 C=3 ..... How can I put into a matlab function to look for value of C? Thanks in advanced!
From: Image Analyst on 8 Aug 2010 22:12 Didn't I just answer that in your duplicate post: http://www.mathworks.com/matlabcentral/newsreader/view_thread/288818
From: Khanh on 8 Aug 2010 22:24 "Image Analyst" <imageanalyst(a)mailinator.com> wrote in message <i3no5k$qpk$1(a)fred.mathworks.com>... > Didn't I just answer that in your duplicate post: > http://www.mathworks.com/matlabcentral/newsreader/view_thread/288818 Image Analyst, I wasn't sure I post the 1st message, so...Sorry for double posting the same type of question. I try to use textscan, but i can only read a certain line from a certain line. I have multiple files that have similar formats but the value that I want to read lie on different lines on different files. I read couple example online but still haven't quite perfect the function. My question now is how to count how many lines to skip when reading a txt file up to a certain symbols. For example, *.txt file line 1 line 2 .... .... NO = 123 .... I want to use headerlines to skip until the line with "NO = 123" and read this value of "123". Do you have any suggestion? I read your the other reply but the more I search, the more confused I get.
From: ImageAnalyst on 8 Aug 2010 22:47 Use fopen to open the file. Then start a loop where you call fgetl(). Then (in the loop) test the string for "NO = 123" using strfind(), strcmpi() or similar functions. When found, break out of the loop. Then get the next line with fgetl() and use sscanf() to extract the numbers out of it.
From: Khanh on 9 Aug 2010 12:04 ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <b05e6dd2-e760-4dc2-95bf-fcb34b9e239a(a)l14g2000yql.googlegroups.com>... > Use fopen to open the file. Then start a loop where you call > fgetl(). Then (in the loop) test the string for "NO = 123" using > strfind(), strcmpi() or similar functions. When found, break out of > the loop. Then get the next line with fgetl() and use sscanf() to > extract the numbers out of it. Thank you. Here is what I did... for those who need it clear clc fid=fopen('mydata.txt'); for i=1:1:13 tline=fgetl(fid); if strfind(tline,'NO =')==77 linumb=i; end end fclose(fid); fid=fopen('mydata.txt') pre_linumb=linumb-1 for i=1:pre_linumb tline=fgetl(fid); end tline=fgetl(fid); a=textscan(tline,'%s = %f %s = %f %s = %f'); a{5} a{6}
|
Next
|
Last
Pages: 1 2 Prev: Dealing with a blank datenum result? Next: Difference Mean Opinion Score (DMOS) for image/video/Voice Quality? |