
ttempted to access w(2); index out of bounds because numel(w)=1 由这句话知道是w变量数组下标越界了,问题应该出来这几句 for i=1:1:n if w(i)>=0 W(i)=w(i); else W(i)=-w(i); end; end; 再由你的for条件i=1:1:n

ttempted to access w(2); index out of bounds because numel(w)=1 由这句话知道是w变量数组下标越界了,问题应该出来这几句 for i=1:1:n if w(i)>=0 W(i)=w(i); else W(i)=-w(i); end; end; 再由你的for条件i=1:1:n