将文本转换为整数的函数带有未定义的错误

问题描述

我从教授的网页复制了以下代码

function y = text2int (x)
% This function takes the letter in the string x and converts
% it to an integer. 
% The convention for this function is
%   a  --> 0
%   b  --> 1
%   and so on...

if ( (x < 'a') | (x > 'z') ),error('Text character out of range a-z');
end;

y=x - 'a';   %It helps to kNow Matlab tricks

但是,当我在Octave中运行它时,出现以下错误

error: 'x' undefined near line 9 column 7
error: called from
    text2int at line 9 column 1

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)