From: John Lenehan on
Hey Everybody,

I'm very new to this so the answer may be very simple, but I am dealing with a very large array (several million data points) and I want to be able to create a new array where certain data points from the original would be removed (set to zero). I acquired this array from an audio file and I just want to eliminate any of the static (the lower amplitude data points). I have been trying to create a filter for this but since I am a beginner I am having difficulty with it. My overall goal is very simple, just set a point to zero if it is between say a and b and keep the other points. Whether I remove these points with a filter or through multiplying the data points within the a and b parameter by 0 doesn't matter, I just don't really know how to do it either way. :P Any help would be appreciated.

-John
From: Garrett on
Hey John,

I had to make a code that did much the same thing for my data analysis. The way I went about it was to set a background (user defined is easiest) and then use the 'find' function to search for all points below that limit. I then replace all of these points with 0 or whatever else I wanted to use.

So if you have an array A and you want to make B where the values below limit L are set to zero then this is the code I would use.

below_limit = find(A <= L) %Finds all values below L
A(below_limit) = 0; %Sets all values in A below L to 0

-Garrett
From: Wayne King on
"John Lenehan" <lenehan2remove.this(a)tcnj.edu> wrote in message <i1fa8g$dsv$1(a)fred.mathworks.com>...
> Hey Everybody,
>
> I'm very new to this so the answer may be very simple, but I am dealing with a very large array (several million data points) and I want to be able to create a new array where certain data points from the original would be removed (set to zero). I acquired this array from an audio file and I just want to eliminate any of the static (the lower amplitude data points). I have been trying to create a filter for this but since I am a beginner I am having difficulty with it. My overall goal is very simple, just set a point to zero if it is between say a and b and keep the other points. Whether I remove these points with a filter or through multiplying the data points within the a and b parameter by 0 doesn't matter, I just don't really know how to do it either way. :P Any help would be appreciated.
>
> -John

Hi John, you can also just use logical indexing.

Say you have a matrix A

A = randn(10,10);

and you want to set all values in A in the interval (-0.5,0.5) to zero

A(abs(A)<0.5) = 0;

However, if you are trying to filter audio data, I really don't think this is the way to filter your data. At any rate, that is another way to select entries from an array based on some criterion.

Wayne
From: John Lenehan on
"Wayne King" <wmkingty(a)gmail.com> wrote in message <i1h6ad$qqe$1(a)fred.mathworks.com>...
> "John Lenehan" <lenehan2remove.this(a)tcnj.edu> wrote in message <i1fa8g$dsv$1(a)fred.mathworks.com>...
> > Hey Everybody,
> >
> > I'm very new to this so the answer may be very simple, but I am dealing with a very large array (several million data points) and I want to be able to create a new array where certain data points from the original would be removed (set to zero). I acquired this array from an audio file and I just want to eliminate any of the static (the lower amplitude data points). I have been trying to create a filter for this but since I am a beginner I am having difficulty with it. My overall goal is very simple, just set a point to zero if it is between say a and b and keep the other points. Whether I remove these points with a filter or through multiplying the data points within the a and b parameter by 0 doesn't matter, I just don't really know how to do it either way. :P Any help would be appreciated.
> >
> > -John
>
> Hi John, you can also just use logical indexing.
>
> Say you have a matrix A
>
> A = randn(10,10);
>
> and you want to set all values in A in the interval (-0.5,0.5) to zero
>
> A(abs(A)<0.5) = 0;
>
> However, if you are trying to filter audio data, I really don't think this is the way to filter your data. At any rate, that is another way to select entries from an array based on some criterion.
>
> Wayne

Hey Wayne,
Thanks for the help. I actually tried using logical indexing and it did what I needed it to, but I also found that you're right about this not being the best way to filter audio data. I think I have to use the Signal Processing Toolbox and create a filter (which I have no idea how to use yet) and that should probably be a much more efficient way to filter my data.
-John
From: John Lenehan on
"Garrett " <bantong(a)onid.orst.edu> wrote in message <i1fgks$kfa$1(a)fred.mathworks.com>...
> Hey John,
>
> I had to make a code that did much the same thing for my data analysis. The way I went about it was to set a background (user defined is easiest) and then use the 'find' function to search for all points below that limit. I then replace all of these points with 0 or whatever else I wanted to use.
>
> So if you have an array A and you want to make B where the values below limit L are set to zero then this is the code I would use.
>
> below_limit = find(A <= L) %Finds all values below L
> A(below_limit) = 0; %Sets all values in A below L to 0
>
> -Garrett

Hey Garrett,
Thanks for the reply. I actually tried using logical indexing which worked pretty well too.