我得到了一些未记录的 Matlab 代码,并试图弄清楚它的作用。我把我的主要问题放在下面,作为代码中穿插的注释。
% x is an array, I believe of dimension (R, 2)
% I understand that the following line creates a logical array y of the same
% dimensions as x in which every position that has a number (i.e. not Nan)
% contains True.
y=~isnan(x)
for k=1:R
% I don't know if z has been previously defined. Can't find it anywhere
% in the code I've been given. I understand that z is a cell array. The
% logical array indexing of x, I understand basically looks at each row
% of x and creates a 1-column array (I think) of numbers that are not Nan,
% inserting this 1-column array in the kth position in the cell array z.
z{k}=x(k, y(k,:))
end
% MAIN QUESTION HERE: I don't know what the following two lines do. what
% will 'n' and 'm' end up as? (i.e. what dimensions are 'd'?)
d=[z{:,:}]
[m,n]=size(d)