简体   繁体   English

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

[英]MATLAB - The input character is not valid in MATLAB statements or expressions

I am trying to evaluate a formula given in a text file. 我正在尝试评估文本文件中给出的公式。

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

syms Chyl_gi Chyl_ly_release_rate_k

eval(EqRF{1}{1})

The context of text file ReactionFlux.txt is 文本文件ReactionFlux.txt的上下文是

ReactionFlux33 = Chyl_gi*Chyl_ly_release_rate_k

Yet everytime that I try to evaluate the line here, it gives the error 但是每次我尝试在此处评估线时,都会产生错误

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

Is there a hidden whitespace character that is invalid or something? 是否存在一个无效或隐藏的空白字符?

Sometimes textscan will pull up invisible glyphs that are in the file. 有时textscan会提取文件中不可见的字形。 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: 您通常可以通过将提取的行包装在strtrim中来摆脱strtrim ,从而摆脱掉字符串开头和结尾的所有空格:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM