所以这是我的代码:
in=-8:8;
%calculate z
[h,k,l]=meshgrid(in);
z = (h.^2 + k.^2 + l.^2);
%sort absolute values ascending, which allows to use unique
ac=sort(abs([h(:) k(:) l(:)]),2);
%use unique to identify duplicates
[f,g,p]=unique(ac,'rows');
%count
cnt=histc(p,1:max(p));
% create a matrix with all vectors
disp([h(g),k(g), l(g),z(g),cnt])
我只想删除或终止包含z> 59的行,我不能使用break,因为它只适用于for循环或while循环,所以我可以使用其他命令吗?感谢。
答案 0 :(得分:1)
我猜你想要这个:
%// your output matrix you want to filter
output = [h(g),k(g), l(g),z(g),cnt];
%// delete rows containing z > 59 (z is the 4th column)
filtered_output = output(output(:,4) <= 59,:)