Extracting elements of a matrix in the first row and even columns
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dylan Zammit
am 24 Apr. 2017
Bearbeitet: Stephen23
am 24 Apr. 2017
I want to manipulate only the components of a matrix which are int the first row and even columns, so (1, 2), (1, 4), etc. To extract the even columns I used: B(:,2:2:end); and for the elements in the first row: B(1,:);
Combining the two: B(1,:,2:2:end); I would get an empty array. Is there a way to this in a single expression?
0 Kommentare
Akzeptierte Antwort
Stephen23
am 24 Apr. 2017
Bearbeitet: Stephen23
am 24 Apr. 2017
B(1,2:2:end)
As the documentation clearly explains, the first position is for rows, the second for columns, the third for pages, etc. Exactly like in the Mathematics that you learned at high school:
array(row,col,page,...)
This very basic MATLAB (and Maths) syntax is explained in the introductory tutorials, which are highly recommended for all beginners:
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!