How to reshape and rearrange a matrix in a specific way

조회 수: 1 (최근 30일)
Cathal White
Cathal White 2020년 10월 20일
댓글: Stephen23 2020년 10월 20일
How can I rearrange the following 3x2 matrix: [0, 0; -0.001, 0; 0, 0.02]
to look like this 6x1: [0; 0; -0.001; 0; 0; 0.02]?
I've tried the reshape function but think I'm using the wrong arguments. Thanks.

채택된 답변

KSSV
KSSV 2020년 10월 20일
편집: KSSV 2020년 10월 20일
If A is matrix. USe
iwant = A(:)
Example:
A = [0, 0; -0.001, 0; 0, 0.02] ;
A = A' ;
iwant = A(:)
  댓글 수: 3
Cathal White
Cathal White 2020년 10월 20일
Brilliant. That edit worked. Thanks.
Stephen23
Stephen23 2020년 10월 20일
Rather than using complex conjugate transpose, it is better to use transpose:
>> A = [0, 0; -0.001, 0; 0, 0.02]
A =
0.0000 0.0000
-0.0010 0.0000
0.0000 0.0200
>> B = A.';
>> B = B(:)
B =
0.0000
0.0000
-0.0010
0.0000
0.0000
0.0200

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by