微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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

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

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 举报,一经查实,本站将立刻删除。