数学建模社区-数学中国

标题: 求教matlab超出索引范围 [打印本页]

作者: desire渴慕    时间: 2015-8-22 17:03
标题: 求教matlab超出索引范围
本人是matlab新手。我是想通过for和if语句判断某一列中的元素是否为需要元素,如果是则改成所需要的值,但是用matlab编程后出现错误,说是超出索引范围,求教我应该怎么改?万分感谢!
clc;clear all;
x=xlsread('1');
xhun=x(:,15);
i=length(xhun)
for k=1:i
    if(xhun(k,15)==1)
        xhun(k,15)=3.5
   else if(xhun(k,15==2))
            xhun(k,15)=4.5
     else   if(xhun(k,15)==3)
            xhun(k,15)=2.5
         end
       end
     end
  end







欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5