Removing Unwanted Data Points

Started by Nick13WV April 30, 2002
I would like to remove all of the "zeros" from a data array.

For Example
I would like to change: A=[1 3 7 0 4 6 9 6]
to A=[1 3 7 4 6 9 6]

I have tried the following:
for i=1:1:length(A)
if A(i)==0
A(i)=[];
end
end



use the nonzeros function ...
----- Original Message -----
From: "Nick13WV" <>
To: <>
Sent: Tuesday, April 30, 2002 6:03 PM
Subject: [matlab] Removing Unwanted Data Points > I would like to remove all of the "zeros" from a data array.
>
> For Example
> I would like to change: A=[1 3 7 0 4 6 9 6]
> to A=[1 3 7 4 6 9 6]
>
> I have tried the following:
> for i=1:1:length(A)
> if A(i)==0
> A(i)=[];
> end
> end >
>
> _____________________________________
> Note: If you do a simple "reply" with your email client, only the author
of this message will receive your answer. You need to do a "reply all" if
you want your answer to be distributed to the entire group.
>
> _____________________________________
> About this discussion group:
>
> To Join:
>
> To Post:
>
> To Leave:
>
> Archives: http://www.yahoogroups.com/group/matlab
>
> More DSP-Related Groups: http://www.dsprelated.com/groups.php3
>
> ">http://docs.yahoo.com/info/terms/ >




This would do the trick

A = A(A ~= 0);

Good luck

- Srivat
----- Original Message -----
From: Nick13WV
To:
Sent: Tuesday, April 30, 2002 6:03 PM
Subject: [matlab] Removing Unwanted Data Points I would like to remove all of the "zeros" from a data array.

For Example
I would like to change: A=[1 3 7 0 4 6 9 6]
to A=[1 3 7 4 6 9 6]

I have tried the following:
for i=1:1:length(A)
if A(i)==0
A(i)=[];
end
end _____________________________________
Note: If you do a simple "reply" with your email client, only the author of
this message will receive your answer. You need to do a "reply all" if you want
your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:

To Post:

To Leave:

Archives: http://www.yahoogroups.com/group/matlab

More DSP-Related Groups: http://www.dsprelated.com/groups.php3


This would do the trick

A = A(A ~= 0);

Good luck

- Srivat
----- Original Message -----
From: Nick13WV
To:
Sent: Tuesday, April 30, 2002 6:03 PM
Subject: [matlab] Removing Unwanted Data Points I would like to remove all of the "zeros" from a data array.

For Example
I would like to change: A=[1 3 7 0 4 6 9 6]
to A=[1 3 7 4 6 9 6]

I have tried the following:
for i=1:1:length(A)
if A(i)==0
A(i)=[];
end
end _____________________________________
Note: If you do a simple "reply" with your email client, only the author of
this message will receive your answer. You need to do a "reply all" if you want
your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:

To Post:

To Leave:

Archives: http://www.yahoogroups.com/group/matlab

More DSP-Related Groups: http://www.dsprelated.com/groups.php3


use the nonzeros function ...
----- Original Message -----
From: "Nick13WV" <>
To: <>
Sent: Tuesday, April 30, 2002 6:03 PM
Subject: [matlab] Removing Unwanted Data Points > I would like to remove all of the "zeros" from a data array.
>
> For Example
> I would like to change: A=[1 3 7 0 4 6 9 6]
> to A=[1 3 7 4 6 9 6]
>
> I have tried the following:
> for i=1:1:length(A)
> if A(i)==0
> A(i)=[];
> end
> end >
>
> _____________________________________
> Note: If you do a simple "reply" with your email client, only the author
of this message will receive your answer. You need to do a "reply all" if
you want your answer to be distributed to the entire group.
>
> _____________________________________
> About this discussion group:
>
> To Join:
>
> To Post:
>
> To Leave:
>
> Archives: http://www.yahoogroups.com/group/matlab
>
> More DSP-Related Groups: http://www.dsprelated.com/groups.php3
>
> ">http://docs.yahoo.com/info/terms/ >




I would like to remove all of the "zeros" from a data array.

For Example
I would like to change: A=[1 3 7 0 4 6 9 6]
to A=[1 3 7 4 6 9 6]

I have tried the following:
for i=1:1:length(A)
if A(i)==0
A(i)=[];
end
end