matlab if语句如何使用
functiony=f(x)y=zeros(size(x));[mn]=size(x);fori=1:mforj=1:nifx(i,j)<=300y(i,j)=20els...
function y=f(x)
y=zeros(size(x));
[m n]=size(x);
for i=1:m
for j=1:n
if x(i,j)<=300
y(i,j)=20
else if x(i,j)<=350
y(i,j)=23
else if x(i,j)<=400
y(i,j)=26
else if x(i,j)<=450
y(i,j)=29
else if x(i,j)<=500
y(i,j)=32
else if x(i,j)<=600
y(i,j)=37
else if x(i,j)<=700
y(i,j)=44
else if x(i,j)<=800
y(x,y)=50
else if x(i,j)<=900
y(i,j)=55
else if x(i,j)<=1000
y(i,j)=60
else
y(i,j)=(x(i,j)-1000)/20
end
end
end
end
end
end
end
end
end
end
y(i,j)
代码有神什么错误,麻烦指出 。最好给个例子 展开
y=zeros(size(x));
[m n]=size(x);
for i=1:m
for j=1:n
if x(i,j)<=300
y(i,j)=20
else if x(i,j)<=350
y(i,j)=23
else if x(i,j)<=400
y(i,j)=26
else if x(i,j)<=450
y(i,j)=29
else if x(i,j)<=500
y(i,j)=32
else if x(i,j)<=600
y(i,j)=37
else if x(i,j)<=700
y(i,j)=44
else if x(i,j)<=800
y(x,y)=50
else if x(i,j)<=900
y(i,j)=55
else if x(i,j)<=1000
y(i,j)=60
else
y(i,j)=(x(i,j)-1000)/20
end
end
end
end
end
end
end
end
end
end
y(i,j)
代码有神什么错误,麻烦指出 。最好给个例子 展开
展开全部
为for加2个end就好了。
function y=f(x)
y=zeros(size(x));
[m n]=size(x);
for i=1:m
for j=1:n
if x(i,j)<=300
y(i,j)=20
else if x(i,j)<=350
y(i,j)=23
else if x(i,j)<=400
y(i,j)=26
else if x(i,j)<=450
y(i,j)=29
else if x(i,j)<=500
y(i,j)=32
else if x(i,j)<=600
y(i,j)=37
else if x(i,j)<=700
y(i,j)=44
else if x(i,j)<=800
y(x,y)=50
else if x(i,j)<=900
y(i,j)=55
else if x(i,j)<=1000
y(i,j)=60
else
y(i,j)=(x(i,j)-1000)/20
end
end
end
end
end
end
end
end
end
end
end
end
y(i,j)
function y=f(x)
y=zeros(size(x));
[m n]=size(x);
for i=1:m
for j=1:n
if x(i,j)<=300
y(i,j)=20
else if x(i,j)<=350
y(i,j)=23
else if x(i,j)<=400
y(i,j)=26
else if x(i,j)<=450
y(i,j)=29
else if x(i,j)<=500
y(i,j)=32
else if x(i,j)<=600
y(i,j)=37
else if x(i,j)<=700
y(i,j)=44
else if x(i,j)<=800
y(x,y)=50
else if x(i,j)<=900
y(i,j)=55
else if x(i,j)<=1000
y(i,j)=60
else
y(i,j)=(x(i,j)-1000)/20
end
end
end
end
end
end
end
end
end
end
end
end
y(i,j)
更多追问追答
追问
加了 还是不行 显示第二行有错,求指点
追答
y=zeros(size(3))
第二行语法没错。逻辑的问题。
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询