早教吧 育儿知识 作业答案 考试题库 百科 知识分享

matlab多变量函数求最值Attempttoaccessminimum(-20,0,1.2)indexmustbeapositiveintegerlogical求最小受力minimum的值,刚刚接触matlab,r=1.2:0.01:2.2;theta=-20:1:80;delta=0:1:100;m=4;g=9.8;L=4;c2=(2.2^2-1.2^2)./(co

题目详情
matlab多变量函数求最值Attempt to access minimum(-20,0,1.2)index must be a positive integer logical
求最小受力 minimum的值,刚刚接触matlab,
r = 1.2:0.01:2.2;
theta = -20:1:80;
delta = 0:1:100;
m = 4;
g = 9.8;
L = 4;
c2 = (2.2^2 - 1.2^2)./(cos(delta - 20) - cos(delta + 80));
c1 = 2.2^2 + c2.*cos(delta +80);
a = (sqrt(c1 +c2) + sqrt(c1 - c2))/2;
b = c2/(2*a);
x = 1000000;
for theta = -20:1:100
for delta = 0:1:100
for r = 1.2:0.01:2.2
minimum = m.*r*g*L.*cos(theta)'./a.*b.*sin(theta + delta);
if minimum(theta,delta,r) < x
x = minimum(theta,delta,r);
end
end
end
end
disp (x)
▼优质解答
答案和解析
minimum(theta,delta,r)
下标只能是正数.你的theta & r都不符合要求,你的minimun是一个数组,而不是一个函数
if minimum < x
x = minimum;
end
改成这样子试试