MATLAB: Create a vector from components of old vectors

create matricesmatrices

I have a 3×5 matrix, I want to be able to take the 1st row and the 3rd column to create a row vector. I know how to seperately extract a row and a column, but how would I go about using that in order to create a new vector without typing individual elements?

Best Answer

For a matrix A such as
A = rand(3,5);
this should work:
v = [A(1,:) A(:,3)']