Create a vector from components of old vectors

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

How do you want to combine the 1st row and 3rd column in your row vector?
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

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

More Answers (0)

Categories

Asked:

on 16 Apr 2020

Answered:

on 16 Apr 2020

Community Treasure Hunt

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

Start Hunting!