![]() |
如果文件主要是文本,如何使用MATLAB中的“ Textscan”读取一系列数字?
我有一个包含3个数字的字符串的文本文件,需要将其读入MATLAB。
例如: ####################### # # # Text Text Text # # ####################### Blah blah blah = #### Blah blah blah = #### Blah blah blah = #### Blah blah blah = #### Blah blah blah = #### Blah blah blah = #### I_NEED_THIS_STRING = 1234.5 6789.0 1234.5 !Comment blah blah blah 我需要将这3个数字读入数组。 请帮忙。 谢谢 [B]回答:[/B] 如果大多数文件与您的应用程序无关,建议您使用喜欢的脚本语言或命令行工具进行预处理,以找到相关的行并在其上使用textscan()。 例如,从shell提示符: grep ^I_NEED_THIS_STRING infile > outfile 在Matlab中: fid = fopen('outfile'); C = textscan(fid, 'I_NEED_THIS_STRING = %f %f %f') fclose(fid) 有关更多详细信息,请参见[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/textscan.html"]textscan文档[/URL] 。 [url=https://stackoverflow.com/questions/3620079]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 01:03。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.