too many input arguments. matlab,mean函数出错咨询,Too many input arguments.

各位高手,你们好!!我编写了一下一个程序,就是把矩阵里面的0值用周围值的平均值替换,出现一下问题,就是想咨询一下是怎么改正!!

A=[0 0 0; 0 2 0;0 2 0 ;0 0 0];

[row,col]=find(A==0);

for i=1:length(row)

for j=1:length(col)

if row(i)==1 & col(j)==1 %第一行第一个元素

A(row(i),col(j))=mean(A(row(i),col(j)+1),A(row(i)+1,col(j)+1),A(row(i)+1,col(j)));

else if row(i)==1 & col(j)==length(A(1,:))%第一行最后一个元素

A(row(i),col(j)) = mean(A(row(i),col(j)-1),A(row(i)+1,col(j)-1),A(row(i)+1,col(j)));

else if row(i)==length(A(:,1)) & col(j) ==1 %最后一行第一个数

A(row(i),col(j)) = mean(A(row(i)-1,col(j)),A(row(i)-1,col(j)+1),A(row(i),col(j)+1));

else if row(i)==length(A(:,1)) & col(j) ==length(A(1,:)) %最后一行最后一个数

A(row(i),col(j)) = mean(A(row(i)-1,col(j)),A(row(i)-1,col(j)-1),A(row(i),col(j)-1));

else if  row(i) ==1 & col(j) >=2 & col(j)

A(row(i),col(j)) = mean(A(row(i)-1,col(j)-1),A(row(i)+1,col(j)-1),A(row(i)+1,col(j)),A(row(i)+1,col(j)+1),A(row(i),col(j)+1));

else if  row(i) >=2 & row(i)< length(A(:,1)) , col(j) >=2 & col(j)

A(row(i),col(j)) = mean(A(row(i),col(j)-1),A(row(i)-1,col(j)-1),A(row(i)-1,col(j)),A(row(i)-1,col(j)+1),A(row(i),col(j)+1));

else if  row(i) >=2 & row(i)

A(row(i),col(j)) = mean(A(row(i)-1,col(j)),A(row(i)-1,col(j)+1),A(row(i),col(j)+1),A(row(i)+1,col(j)+1),A(row(i)+1,col(j)));

else if   row(i) >= 2 & row(i) =2 & col(j)

A(row(i),col(j)) = mean(A(row(i)+1,col(j)),A(row(i)+1,col(j)-1),A(row(i),col(j)-1),A(row(i)-1,col(j)-1),A(row(i)-1,col(j)));

else

A(row(i),col(j))=mean(A(row(i),col(j)-1),A(row(i)-1,col(j)-1),A(row(i)-1,col(j)),A(row(i)-1,col(j)+1),A(row(i),col(j)+1),A(row(i)+1,col(j)+1),A(row(i)+1,col(j)),A(row(i)+1,col(j)-1));

end

end

end

end

end

end

end

end

end

end

end

出错如下:

??? Error using ==> mean

Too many input arguments.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值