資源簡介
這個Matlab程序,可以讀取任何文本文件,并返回一個內容的數組。它在執行過程中,對每個字符串進行匹配,每行作為一次匹配的結束。

代碼片段和文件信息
function??????[data?result]=?readtext(text?delimiter?comment?quotes?options)
%??Usage:?????[data?result]=?readtext(source?delimiter?comment?quotes?options)
%?
%?Whatever?text?(file)?you?give?it?readtext?returns?an?array?of?the?contents?(or?send?me?a?
%???bug?report).?Matlab?can‘t?read?variable?length?lines?or?variable?type?values?with?the?standard?
%???library.?readtext?can?read?any?text?file.?Any?string?(or?even?regexp)?can?be?delimiting?
%???default?is?a?comma.?Everything?after?(and?including)?a?comment?character?until?the?line?end?
%???is?ignored.?Quote?characters?may?also?be?given?everything?between?them?is?treated?as?one?item.?
%???There?are?options?to?control?what?will?be?converted?to?numbers?and?how?empty?items?are?saved.?
%?
%?If?you?find?any?errors?please?let?me?know:?peder?at?axensten?dot?se.
%?
%?source:?????the?file?to?be?read.?May?be?a?file?path?or?just?the?file?name.
%?????????OR:?The?text?itself?see?‘textsource‘?below.?
%?
%?delimiter:??(default:?‘‘)?any?non-empty?string.?May?be?a?regexp?but?this?is?slow?on?large?files.?
%?
%?comment:????(default:?‘‘)?zero?or?one?character.?Anything?after?(and?including)?this?character?
%???until?the?end?of?the?line?will?be?ignored.?
%?
%?quotes:?????(default:?‘‘)?zero?one?(opening?quote?equals?closing)?or?two?characters?(opening?
%???and?closing?quote)?to?be?treated?as?paired?braces.?Everything?between?the?quotes?will?be?
%???treated?as?one?item.?The?quotes?will?remain.?Quotes?may?be?nested.
%?
%?options:????(default:?‘‘)?may?contain?(concatenate?combined?options):?
%?-?‘textsource‘:?source?contains?the?actual?text?to?be?processed?not?the?file?name.
%?-?‘textual‘:?no?numeric?conversion?(‘data‘?is?a?cell?array?of?strings?only)?
%?-?‘numeric‘:?everything?is?converted?to?a?number?or?NaN?(‘data‘?is?a?numeric?array?empty?items?
%???are?converted?to?NaNs?unless?‘empty2zero‘?is?given)?
%?-?‘empty2zero‘:?an?empty?field?is?saved?as?zero?and?
%?-?‘empty2NaN‘:?an?empty?field?is?saved?as?NaN.?
%?-?‘usewaitbar‘:?call?waitbar?to?report?progress.?If?you?find?the?wait?bar?annoying?get?‘waitbar?
%???alternative‘?at?http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=11398
%?
%?data:???????A?cell?array?containing?the?read?text?divided?into?cells?by?delimiter?and?line?
%???endings.?‘data‘?will?be?empty?if?the?file?is?not?found?could?not?be?opened?or?is?empty.?
%???With?the?option?‘numeric‘?‘data‘?will?be?a?numeric?array?with?‘textual‘?‘data‘?will?be?a?
%???cell?array?of?strings?only?and?otherwise?it?will?be?a?mixed?cell?array.?For?Matlab?%???returned?strings?may?contain?leading?white-space.
%?
%?result:?????a?structure:
%?.min:?minimum?number?of?columns?found?in?a?line.
%?.max:?number?of?columns?in?‘data‘?before?removing?empty?columns.
%?.rows:?number?of?rows?in?‘data‘?before?removing?empty?rows.?
%?.numberMask:?true?if?numeric?conversion?(‘NaN‘?converted?to?NaN?counts).
%?.number:?number?of?nume
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????102??2008-06-21?12:52??loadFile.do_files\00th.png
?????文件?????????96??2008-06-21?12:52??loadFile.do_files\90th.png
?????文件????????646??2008-06-21?12:52??loadFile.do_files\blue_band_536x5.gif
?????文件?????????57??2008-06-21?12:52??loadFile.do_files\bullet.gif
?????文件???????6693??2008-06-21?12:52??loadFile.do_files\Captcha.htm
?????文件??????10462??2008-06-21?12:52??loadFile.do_files\cmnty1.css
?????文件?????????70??2008-06-21?12:52??loadFile.do_files\doc.gif
?????文件?????????97??2008-06-21?12:52??loadFile.do_files\dots_rnav.gif
?????文件????????152??2008-06-21?12:52??loadFile.do_files\dots_rnav_top.gif
?????文件?????????64??2008-06-21?12:52??loadFile.do_files\exclamation.gif
?????文件????????145??2008-06-21?12:52??loadFile.do_files\fullstar.gif
?????文件????????145??2008-06-21?12:52??loadFile.do_files\fullstar_grey.gif
?????文件????????140??2008-06-21?12:52??loadFile.do_files\halfstar.gif
?????文件????????117??2008-06-21?12:52??loadFile.do_files\ltblue_top_nav_trans.gif
?????文件????????155??2008-06-21?12:52??loadFile.do_files\mail_brdr.gif
?????文件???????2569??2008-06-21?12:52??loadFile.do_files\mlc_logo.gif
?????文件?????????64??2008-06-21?12:52??loadFile.do_files\question.gif
?????文件?????????43??2008-06-21?12:52??loadFile.do_files\s99813412818231.gif
?????文件???????3379??2008-06-21?12:52??loadFile.do_files\site3.css
?????文件?????????43??2008-06-21?12:52??loadFile.do_files\spacer.gif
?????文件?????????66??2008-06-21?12:52??loadFile.do_files\submitfile.gif
?????文件??????39399??2008-06-21?12:52??loadFile.do_files\s_code.js
?????文件????????260??2008-06-21?12:52??loadFile.do_files\xm
?????目錄??????????0??2008-06-21?12:52??loadFile.do_files
?????文件??????51796??2008-06-21?12:52??loadFile.do.htm
?????文件??????20055??2008-06-21?12:52??readtext.m
-----------?---------??----------?-----??----
???????????????136815????????????????????26
- 上一篇:LS信道估計算法仿真代碼
- 下一篇:基于multisim的555多諧振蕩器
評論
共有 條評論