MATLAB - 输入字符在MATLAB语句或表达式中无效

时间:2016-03-04 16:30:40

标签: matlab parsing evaluation

我正在尝试评估文本文件中给出的公式。

fid = fopen('ReactionFlux.txt')
EqRF = textscan(fid, '%s', 'Delimiter', {'\n'});
fclose(fid);

syms Chyl_gi Chyl_ly_release_rate_k

eval(EqRF{1}{1})

文本文件ReactionFlux.txt的上下文是

ReactionFlux33 = Chyl_gi*Chyl_ly_release_rate_k

然而,每当我尝试在此处评估线条时,它都会给出错误

Error: The input character is not valid in MATLAB statements or expressions.

是否存在无效的隐藏空白字符或其他内容?

1 个答案:

答案 0 :(得分:0)

Sometimes textscan will pull up invisible glyphs that are in the file. You can get usually get rid of them by wrapping the extracted line in strtrim, which gets rid of all whitespace at the beginning and end of a string:

eval(strtrim(EqRF{1}{1}))