MATLAB Answers

Making a row vector from a nxn matrix

5 views (last 30 days)
Jalal Hassan
Jalal Hassan on 25 Jun 2020
Commented: Matt J on 26 Jun 2020
I have a nxn matrix and I want to make n row vectors from that matrix.
For example, I have a Matrix
A = 3×3
1 2 3
4 5 6
7 8 9
From this, I want 3 matrices of order 1x3
B = [1 2 3]
C = [4 5 6]
D = [7 8 9]
I want this to be processed by Matlab itslef.

Accepted Answer

Matt J
Matt J on 25 Jun 2020
Edited: Matt J on 25 Jun 2020
>> BCD=num2cell(A,2);
>> BCD{:}
ans =
1 2 3
ans =
4 5 6
ans =
7 8 9
  2 Comments
Matt J
Matt J on 26 Jun 2020
Show me what you plan to do with B,C,D and I will show you how to accomplish ti with num2cell.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!