How to select a specific column in matrices?
77 views (last 30 days)
I have four (4x4) matrices A B C D. I need to put all the second colums of the four matrices in another matrix X. I tried using
xdatatemp = xdata(:,[end 2]); X = xdatatemp
but it shows an error. Thank you in advance!
Star Strider on 7 Jun 2021
Concatenate them, then select the second column of the concatenated matrix —
A = randi(9,4)
B = randi(9,4)
C = randi(9,4)
D = randi(9,4)
ABCD = cat(3,A,B,C,D)
NewMatrix = squeeze(ABCD(:,2,:)) % Elimiinate Singleton Dimensions with 'squeeze'