uniform density, matrix

2 vues (au cours des 30 derniers jours)
PChoppala
PChoppala le 15 Oct 2011
Hi there, I am working on a new project starting last week, and hence I have been asking too many questions. Thanks for all who helped me.
Again, I have 3 simple queries looking for suggestions ASAP.
I am working on particle filter where I need to initialize the velocity, Intensity and position of (say N = 100) particles
Can you suggest me the M-code for
1. Drawing a value for the velocity from the uniform distribution
v ~ U[-vmax, vmax] , where vmax = 1 unit/sec
2. Drawing a value for intensity from the uniform distribution
I ~ U[Imin, Imax] , where Imin = 10, Imax = 30
3. I have a matrix(or a frame(image) in my case) called 'z', say its a 3x3 frame.
x = [1.2, 0.45, 0.2, 0.25, 20]';
n=3;
m=3;
blur = 0.7;
a = 3.*randn(n,m);
for i=1:n
for j=1:m
if i-x(1) < 3 && j-x(3) <3
h(i,j) = x(5)/(2 * pi * (blur^2)) * exp(-((i-x(1))^2 + (j-x(3))^2)/ (2* (blur^2)))
else
h(i,j) = 0
end
end
end
z = a + h;
So, 'z' will be a 3x3 frame having certain values for the pixels.
The values in 'x' are [position in x-axis, velocity in x-axis, position in y-axis, velocity in y-axis, Intensity].
So the pixels in frame 'z' that fall in the vicinity of the position given my 'x' in x-y direction will have higher values(Intensity than others)
now, what I want is, the position of the particles should be initialized from the distribution q(x,y | z) is a uniform density over those regions in 'z' for which z(i,j) > T
T = threshold = 2
I need to draw values from that distribution.
Okay, I assume I have made myself clear. Can you friends please help!
Many thanks
P

Réponse acceptée

the cyclist
the cyclist le 15 Oct 2011
Do you have the Statistics Toolbox? You can use the function unifrnd() to do at least some of what you need.
  1 commentaire
PChoppala
PChoppala le 15 Oct 2011
So that would solve my 1 & 2 points
1. x1 = unifrnd(-1,1,2,N)
2. x2 = unifrnd(10,30,1,N)
Can you help m out with the third?
Thanks

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics 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