MATLAB将txt中的文本替换成数值? 50
我有好多个txt文件,存储的为数据,但这些数据有部分字符“1.#QNAN0”,导致MATLAB读取数据失败。现在我想把这些“1.#QNAN0”全部替换成-999,请问要怎...
我有好多个txt文件,存储的为数据,但这些数据有部分字符“1.#QNAN0”,导致MATLAB读取数据失败。现在我想把这些“1.#QNAN0”全部替换成-999,请问要怎么做?
展开
1个回答
展开全部
function findreplace(file,otext,ntext,varargin)
%FINDREPLACE finds and
replaces strings in a text file
%
% SYNTAX:
%
%
findreplace(file,otext,ntext)
% findreplace(file,otext,ntext,match)
%
%
findreplace : This function finds and replaces strings in a text file
%
%
file: text file name (with or without path)
% otext: text to be replaced (old
text)
% ntext: replacing text (new text)
% match: either (1) for match
case or (0) to ignore case
% default value is (1)
例如:findreplace(file.txt,A,1,1)或者findreplace(file.txt,A,1,0)
你可以写个小程序试验一下,或者help findreplace
%FINDREPLACE finds and
replaces strings in a text file
%
% SYNTAX:
%
%
findreplace(file,otext,ntext)
% findreplace(file,otext,ntext,match)
%
%
findreplace : This function finds and replaces strings in a text file
%
%
file: text file name (with or without path)
% otext: text to be replaced (old
text)
% ntext: replacing text (new text)
% match: either (1) for match
case or (0) to ignore case
% default value is (1)
例如:findreplace(file.txt,A,1,1)或者findreplace(file.txt,A,1,0)
你可以写个小程序试验一下,或者help findreplace
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询