注册 登录
编程论坛 Matlab

循环语句和找最小值

jxnfnd 发布于 2007-01-07 14:58, 1429 次点击
请问以下代码,有什么结果?我在MatLab6.5上运行出了错,不知为什么?
m=10;
g=9.8;
for? μ=0:0.1:1;
x=0:0.5:90;
x1=x*pi/180;
f=m*g*μ./(cos(x1)+μ*sin(x1));
plot(x,f)
hold on?
f1=min(f)
x2=find(f=f1)-1
end
axis?([0,90,0,100])
1 回复
#2
zhangenter2007-01-07 17:07
1.μ在不能作为变量
2.里面有中文空格,在代码里这是非法字符
3.find函数不是这样用的,应该改成find(f==f1)

m=10;
g=9.8;
for y=0:0.1:1;
x=0:0.5:90;
x1=x*pi/180;
f=m*g*y./(cos(x1)+y*sin(x1));
plot(x,f)
hold on
f1=min(f)
x2=find(f==f1)-1
end
axis([0,90,0,100])
1