How can pick a specific values (rows,columns) from a matrix?
283 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Abdulatif Alabdulatif
am 25 Okt. 2014
Beantwortet: Nani Venky
am 14 Apr. 2021
Hi all,
I want to process a part of large a matrix. Let's assume we have a matrix with 10 rows and 10 columns, I want to pick a small matrix from it with 4 rows and 5 columns. How can I do it?
Thank you
0 Kommentare
Akzeptierte Antwort
Nick
am 25 Okt. 2014
if a = rand(10,10)
if you want 4 rows and 5 columns you can do a([1:4],[1:5]) and it will give you the first 4 rows and 5 columns. a([4:7],[5:9]) will give you rows 4-7 and columns 5-9 etc.
0 Kommentare
Weitere Antworten (1)
Nani Venky
am 14 Apr. 2021
Previous answers are applicable if you want to select consecutive rows or columns.The below way can be used to select elements from any row and column.
Example:
A = randi(10,6,6);
B = A([1:2 4:end],[1:2 5:end]);
This way you can form a matrix B that contains the element in A except from third row and third and fourth columns.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Multidimensional Arrays 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!