この関数を使用して、すべての要素が 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