MATLAB: Extract certain lines in matrice

extract line matrice

hi everyone i have this matrice
0.8979 0.8979 0.8979 0.8979 0.8979 0.8979 0.8979 0.8979
0.5934 -0.5934 0.5934 -0.5934 0.5934 -0.5934 0.5934 -0.5934
0.5934 0.5934 -0.5934 -0.5934 0.5934 0.5934 -0.5934 -0.5934
0.8979 -0.8979 -0.8979 0.8979 0.8979 -0.8979 -0.8979 0.8979
0.5934 0.5934 0.5934 0.5934 -0.5934 -0.5934 -0.5934 -0.5934
0.8979 -0.8979 0.8979 -0.8979 -0.8979 0.8979 -0.8979 0.8979
0.8979 0.8979 -0.8979 -0.8979 -0.8979 -0.8979 0.8979 0.8979
0.5934 -0.5934 -0.5934 0.5934 -0.5934 0.5934 0.5934 -0.5934
I want to extract the line 1&2&4&7 in order to put them in another equation can anyone give me the code to put certain lines in another place

Best Answer

This is very basic matrix indexing which is covered in the Getting started tutorial:
m = [0.8979 0.8979 0.8979 0.8979 0.8979 0.8979 0.8979 0.8979
0.5934 -0.5934 0.5934 -0.5934 0.5934 -0.5934 0.5934 -0.5934
0.5934 0.5934 -0.5934 -0.5934 0.5934 0.5934 -0.5934 -0.5934
0.8979 -0.8979 -0.8979 0.8979 0.8979 -0.8979 -0.8979 0.8979
0.5934 0.5934 0.5934 0.5934 -0.5934 -0.5934 -0.5934 -0.5934
0.8979 -0.8979 0.8979 -0.8979 -0.8979 0.8979 -0.8979 0.8979
0.8979 0.8979 -0.8979 -0.8979 -0.8979 -0.8979 0.8979 0.8979
0.5934 -0.5934 -0.5934 0.5934 -0.5934 0.5934 0.5934 -0.5934];
subm = m([1 2 4 7], :); %select all columns of rows 1, 2, 4 and 7
Related Question