我是 Matlab 的新手,对于 a、l 和 wi 的值,需要找到数据集中 l 的所有值以及相应的 w 值。
a=10;
l=(0:10)
w=(0:10)
for l,d
if a == l.*w
disp(l)
disp(w)
end
end
我是 Matlab 的新手,对于 a、l 和 wi 的值,需要找到数据集中 l 的所有值以及相应的 w 值。
a=10;
l=(0:10)
w=(0:10)
for l,d
if a == l.*w
disp(l)
disp(w)
end
end
不知道你想做什么,但我认为你的代码可以如下放置:
a = 10;
l = 0:a; %// actually, it would suffice to check numbers up to floor(a/2)
ind = rem(a,l)==0; %// logical index that tells if remainder is zero or not
disp([l(ind); a./l(ind)])
结果:
1 2 5 10
10 5 2 1
factor
你可以用 Matlab 的函数更直接地做到这一点:
f = factor(a);
disp([f; a./f])
结果:
2 5
5 2