フィルターのクリア

delete zeros rows and columns

1 回表示 (過去 30 日間)
Isee You
Isee You 2012 年 3 月 1 日
i try do delete rows and columns that are zeros but it cut also part of shape .I use this code
u=I;
old=[];
new=all(~u);
while ~isequal(old,new)
u(new,:)=0;
old=new;
new=all(~u);
end
u(new,:)=[];
u(:,new)=[];
av=u;
av(~any(u,2),:)=[];
%radious of puple
figure, imshow(av,[]);
so any other way to do that

採用された回答

Jonathan Sullivan
Jonathan Sullivan 2012 年 3 月 2 日
u = I;
zc = ~any(u);
u(:,zc) = [];
zr = ~any(u,2);
u(zr,:) = [];
  1 件のコメント
Isee You
Isee You 2012 年 3 月 2 日
thank u "Jonathan Sullivan"

サインインしてコメントする。

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2012 年 3 月 1 日
u = I;
zc = ~any(u);
zr = ~any(u,2);
u(zc,zr) = [];
imshow(u, []);
  1 件のコメント
Isee You
Isee You 2012 年 3 月 2 日
i try this code but i get this error
Subscripted assignment dimension mismatch.
Error in first_step_to_final (line 110)
u(zc,zr) = [];
why? how to solve it

サインインしてコメントする。


Andrea
Andrea 2012 年 5 月 30 日
data( all( ~any( data), 2 ), : ) = []; % removes all rows with all zero
data( :, all( ~any( data ), 1 ) ) = []; % and columns

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by