# creating matrix out of another matrix

1 Ansicht (letzte 30 Tage)
mehra am 9 Sep. 2019
Kommentiert: mehra am 9 Sep. 2019
I have a results matrix of size 104*14. I want to create a matrix of size 8*13 in which u(1,1)=results((1:13),4) and....I tried to write the matrix like:
u_mean_Uund=[results(1:13),4; results(14:26),4;results(27:39),4;results(40:52),4;results(53:65),4;...
results(66:78),4;results(79:91),4;results(92:104),4]
But this shows the first column of the results matrix, I actually want a 8*13 matrix in which the arrays are all from column 4.
##### 2 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
mehra am 9 Sep. 2019

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

mehra am 9 Sep. 2019
I solved it using following for loop:
for nn=1:8
u_depth(nn,:)=transpose(results((13*(nn)-12):13*(nn),4));
end
##### 4 Kommentare3 ältere Kommentare anzeigen3 ältere Kommentare ausblenden
mehra am 9 Sep. 2019
Well... I dont know niether you nor Stephen and I dont want to argue with anyone...i was rushing to get the answer as soon as possible, so I also worked on that... Anyway i think you cant judge people like this...and again I thanks everyone for their answers and their help.

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (1)

Stephen23 am 9 Sep. 2019
Bearbeitet: Stephen23 am 9 Sep. 2019
out = reshape(results(:,4),13,8).';
out(:,14) = 4; % if you want an 8x14 matrix
##### 10 Kommentare9 ältere Kommentare anzeigen9 ältere Kommentare ausblenden
mehra am 9 Sep. 2019
Anyway i am happy that my solution also works

Melden Sie sich an, um zu kommentieren.

### Kategorien

Find more on Loops and Conditional Statements in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by