我使用這個函數來獲得一個列向量,其中每個元素應該是1, ,但是在n變大後,有時某個元素不是1,這是由於方法約束,我想知道n有多大並返回值。問題是:1.似乎1存儲爲1.0000,不知道如何轉換它,以及如何比較(註釋中的位置)2.不知道如何完全退出循環。謝謝。在matlab退出整個循環和更多
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