how to delete a digit from an array ???

1 vue (au cours des 30 derniers jours)
Talat
Talat le 5 Juil 2011
Hello! everyone I have a program in which i have one array of binary numbers and a loop... i wana that if the condition in loop is true then one binary number must be deleted from array... , suppose {
A=[0 0 1 1 1 1 0 0 0 0 0 0 1 1 1 ]
if ( A == 0 & F(i, j)==255)
"then delete 0 from array"
end}
which function should i use to delete a digit from array...plz help me. Thanks in advance

Réponse acceptée

Waleed El-Badry
Waleed El-Badry le 5 Juil 2011
Hi,
Here is another implementation if want to look at the empty half :-)
A=[1 1 1 0 0 0 0 1 1 0];
[~,s]=size(A);
cnt=1;
ind=[];
for i=1:s
if A(i)==0
ind(cnt)=i;
cnt=cnt+1;
end
end
A(ind)=[]; % removing elements
You have a choice of a being a hardcore developer like me or atomic one like the line of code by Sean :-)
Hope it helps
  1 commentaire
Talat
Talat le 6 Juil 2011
Thanks both of you guys... it will help me for sure

Connectez-vous pour commenter.

Plus de réponses (1)

Sean de Wolski
Sean de Wolski le 5 Juil 2011
B = A(~A & F(i,j)~=255)
  2 commentaires
Oleg Komarov
Oleg Komarov le 5 Juil 2011
Sean keeps those which not match the deletion criteria = delete those which match criteria.
Sean de Wolski
Sean de Wolski le 5 Juil 2011
Glass half full :-)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by