What does this mean in MATLAB?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have came about a MATLAB code like the following:
xyz = imfilter(A,B);
xyz_subsample = xyz(1:2:size(xyz, 1), 1:2:size(xyz, 2));
The code is related to subsampling. But, what does the second line mean?
Thanks.
1 comentario
Jan
el 10 de Nov. de 2013
@med-sweng: Your questions have a very low acceptance rate. This usually means, that there is a problem in the way you ask. In long term, this can discourage contributors to spend the time for answering your questions. So it is in your own interest to clarify your questions until they can be answered successfully, and accept this answer then.
Respuestas (2)
the cyclist
el 10 de Nov. de 2013
Suppose xyz is a 256x512 matrix. Then
size(xyz,1)
is 256 and
size(xyz,2)
is 512.
The code
1:2:size(xyz,1)
is a vector counting by 2's:
[1 3 5 7 ... 255]
and likewise for the second dimension.
So, the whole code is subsampling by only selecting every 2nd element of both the x and y dimensions.
2 comentarios
the cyclist
el 11 de Nov. de 2013
As Jan also describes, your code keeps rows 1,3,5,... and columns 1,3,5 ... .
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!