From: Ali Culp on 6 Jul 2010 13:54 I have a matrix which when plotted as a histogram has a relatively normal distribution. What I want to do is set all elements in the matrix that fall within two standard deviations on either side of the histogram's peak equal to zero. For instance, if the "-" are my histogram, I want to set all of the values within the "|" lines equal to zero: | - | -| | - - | | - - | | - - | | - - | | - | | Any ideas how I can do this?
From: someone on 6 Jul 2010 14:19 "Ali Culp" <aliculp(a)hotmail.com> wrote in message <i0vqjs$f2i$1(a)fred.mathworks.com>... > I have a matrix which when plotted as a histogram has a relatively normal distribution. What I want to do is set all elements in the matrix that fall within two standard deviations on either side of the histogram's peak equal to zero. > > For instance, if the "-" are my histogram, I want to set all of the values within the "|" lines equal to zero: > > | - | > -| | - > - | | - > - | | - > - | | - > - | | - > | | > > Any ideas how I can do this? > You might try something like: xm = mean(x) % or meadian or or mode or however you define the "peak" xd = std(x) % standard deviation x(x>(xm-2*xd) & x<(xm+2*xd) = 0
From: Ali Culp on 6 Jul 2010 16:05 "someone" <someone(a)somewhere.net> wrote in message <i0vs2p$lna$1(a)fred.mathworks.com>... > "Ali Culp" <aliculp(a)hotmail.com> wrote in message <i0vqjs$f2i$1(a)fred.mathworks.com>... > > I have a matrix which when plotted as a histogram has a relatively normal distribution. What I want to do is set all elements in the matrix that fall within two standard deviations on either side of the histogram's peak equal to zero. > > > > For instance, if the "-" are my histogram, I want to set all of the values within the "|" lines equal to zero: > > > > | - | > > -| | - > > - | | - > > - | | - > > - | | - > > - | | - > > | | > > > > Any ideas how I can do this? > > > > You might try something like: > > xm = mean(x) % or meadian or or mode or however you define the "peak" > xd = std(x) % standard deviation > > x(x>(xm-2*xd) & x<(xm+2*xd) = 0 Okay so that will set the parts of the histogram equal to zero, but how do i then set the elements of the matrix that make up that part of the histogram equal to zero?
From: someone on 6 Jul 2010 16:22 "Ali Culp" <aliculp(a)hotmail.com> wrote in message <i102a0$9ib$1(a)fred.mathworks.com>... > "someone" <someone(a)somewhere.net> wrote in message <i0vs2p$lna$1(a)fred.mathworks.com>... > > "Ali Culp" <aliculp(a)hotmail.com> wrote in message <i0vqjs$f2i$1(a)fred.mathworks.com>... > > > I have a matrix which when plotted as a histogram has a relatively normal distribution. What I want to do is set all elements in the matrix that fall within two standard deviations on either side of the histogram's peak equal to zero. > > > > > > For instance, if the "-" are my histogram, I want to set all of the values within the "|" lines equal to zero: > > > > > > | - | > > > -| | - > > > - | | - > > > - | | - > > > - | | - > > > - | | - > > > | | > > > > > > Any ideas how I can do this? > > > > > > > You might try something like: > > > > xm = mean(x) % or meadian or or mode or however you define the "peak" > > xd = std(x) % standard deviation > > > > x(x>(xm-2*xd) & x<(xm+2*xd) = 0 > > Okay so that will set the parts of the histogram equal to zero, but how do i then set the elements of the matrix that make up that part of the histogram equal to zero? I'm not sure I understand. If x is the matrix you plot with the hist command, doesn't x(x>(xm-2*xd) & x<(xm+2*xd)) = 0 set those elements of x to zero?
From: Ali Culp on 6 Jul 2010 17:27 "someone" <someone(a)somewhere.net> wrote in message <i1039c$dlq$1(a)fred.mathworks.com>... > "Ali Culp" <aliculp(a)hotmail.com> wrote in message <i102a0$9ib$1(a)fred.mathworks.com>... > > "someone" <someone(a)somewhere.net> wrote in message <i0vs2p$lna$1(a)fred.mathworks.com>... > > > "Ali Culp" <aliculp(a)hotmail.com> wrote in message <i0vqjs$f2i$1(a)fred.mathworks.com>... > > > > I have a matrix which when plotted as a histogram has a relatively normal distribution. What I want to do is set all elements in the matrix that fall within two standard deviations on either side of the histogram's peak equal to zero. > > > > > > > > For instance, if the "-" are my histogram, I want to set all of the values within the "|" lines equal to zero: > > > > > > > > | - | > > > > -| | - > > > > - | | - > > > > - | | - > > > > - | | - > > > > - | | - > > > > | | > > > > > > > > Any ideas how I can do this? > > > > > > > > > > You might try something like: > > > > > > xm = mean(x) % or meadian or or mode or however you define the "peak" > > > xd = std(x) % standard deviation > > > > > > x(x>(xm-2*xd) & x<(xm+2*xd) = 0 > > > > Okay so that will set the parts of the histogram equal to zero, but how do i then set the elements of the matrix that make up that part of the histogram equal to zero? > > I'm not sure I understand. > If x is the matrix you plot with the hist command, doesn't > > x(x>(xm-2*xd) & x<(xm+2*xd)) = 0 > > set those elements of x to zero? Okay sorry I see what you're saying. The problem now is that when using A > B, A and B must be the same size and the mean(x) and std(x) do not have the same dimensions as x itself. What I think I need to do is find the mean of all of the individual elements of x (that way it will be a scalar and then > will work)... can this be done?
|
Next
|
Last
Pages: 1 2 Prev: Problems with Legend Box Next: Specify (state dependent) mass matrix in Simulink S-function |