converting a horizontal matrix to vertical

Illustration
Su-chen-christine-lim - 2021-02-11T10:46:32+00:00
Question: converting a horizontal matrix to vertical

Hello. I am trying to convert a 100*2  matrix to 2*100 matrix. I appreciate if you give me any idea. The reason is I need to find the pick of negative data at second column, and I am using following code:     NEG=[find(E(:,1)<0) E(E(:,1)<0,1)]; so for using following code I need my matrix be 2*100 EE=findpeaks(NEG(:,2));

Expert Answer

Profile picture of John Michell John Michell answered . 2025-11-20

Use transpose, which can also be written .'
To convert a horizontal matrix to a vertical matrix in MATLAB, you can use the transpose operation. Here’s a simple example:
 
 
>> A = [1,2;3,4;5,6;,7,8]
A =
     1     2
     3     4
     5     6
     7     8
>> A.'
ans =
     1     3     5     7
     2     4     6     8


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!