我正在使用这个函数来获取一个列向量,其中每个元素都应该是 1,但是在 n 变大之后,有时某些元素不是 1,这是由于方法限制,我想找出 n 有多大并返回值。问题是: 1.似乎 1 存储为 1.0000,不知道如何转换它,以及如何比较(注释中的位置) 2.不知道如何完全退出循环。谢谢你。
function x = findn(n)
for m = 1:n
[a,b]=Hilbert(m);
m1 = GaussNaive(a,b);
m2 = size(m1,1);
% m1 is a n*1 matrix (a column vector) which every element is supposed
% to be 1, but when n gets large, some element is not 1.
for i = 1:m2
if (m1(i) ~= 1)
% this compare isn't really working, since 1 is stored as 1.0000 for whatever
% for whatever reason and they are not equal or not not equal.
% I doubt whether it really compared.
x = m;
break;
% it just exit the inner for loop, not entirely
end
end
end