question about addressing matrix elements
Ältere Kommentare anzeigen
In the 4th line in the code below, I am having difficulty understanding what the -1 is doing. Is that a -1 step size?
Thanks, Chris
G0=zeros(m/2,n);
G0(:,1:2:n)=bay(1:2:m,1:2:n); %bay is a 192x128 double matrix
hh1 = [0 0.5 1 0.5 0];
xx1 = [G0(:,3:-1:2), G0, G0(:,n-1:-1:n-B)];
f1 = conv2(1,hh1,xx1,'valid');
Antworten (1)
James Tursa
am 18 Feb. 2015
Bearbeitet: James Tursa
am 18 Feb. 2015
Yes. The colon operator when used with three values is
starting_value:step:ending_value
e.g.,
5:-1:2
ans =
5 4 3 2
So, the expression
G0(:,3:-1:2)
means "all the rows" and "columns 3 and 2 in that order". I.e., the 3rd and 2nd columns of G0.
Kategorien
Mehr zu Numbers and Precision finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!