How to reshape and rearrange a matrix in a specific way

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.

 Accepted Answer

KSSV
KSSV on 20 Oct 2020
Edited: KSSV on 20 Oct 2020
If A is matrix. USe
iwant = A(:)
Example:
A = [0, 0; -0.001, 0; 0, 0.02] ;
A = A' ;
iwant = A(:)

3 Comments

[0;-1e-03;0;0;0;0.02]
That command gives me back this. Is there a possible way to get what I was looking for without using a loop?
Brilliant. That edit worked. Thanks.
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

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2020a

Asked:

on 20 Oct 2020

Commented:

on 20 Oct 2020

Community Treasure Hunt

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

Start Hunting!