Create a vector from components of old vectors

6 views (last 30 days)
I have a 3x5 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?
  2 Comments
Tommy
Tommy on 16 Apr 2020
How do you want to combine the 1st row and 3rd column in your row vector?
Jordan Shook
Jordan Shook on 16 Apr 2020
I am supposed to create a row vector. Meaning I should take the first row, then make the numbers from the third row follow, in a row like fashion.
i.e row 1: [1,2,3,4,5]
Column 3
1
2
3
new vector [1,2,3,4,5,1,2,3]

Sign in to comment.

Accepted Answer

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

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!