我正在学习Matlab,并且正在编写代码以根据使用'if'的条件来查找特定值。值可以很容易地找到,但我想知道这个值是由阵列A和B的哪些元素创建的。不幸的是,我不能使用这个代码。我真的很感激你的关注。使用Matlab将值赋给循环中的变量
A=[2,7,1,3,10];
B=[2,7,1,3,10];
c=1;
k=0;
f=0;
L=length (A);
for m=1:L-1
for n=m:L
if(A(m)./B(n)> 0.09 && A(m)./B(n)<c)
c=A(m)./B(n);
k=A(m);
f=B(n);
end
end
end
fprintf('the c value is %0.5f',c)
fprintf('the A(m) value is %0.5f',k)
fprintf('the B(n) value is %0.5f',f)
the c value is 0.10000
,正吗? –