obtain a matrix out of other matrix
4 Ansichten (letzte 30 Tage)
I have a 1*104 matrix which ı have to create a 8*13 matrix out of it.
For one column of the final 8*13 matrix I can do the following code but how can I write one single code to get the whole matrix
This gives me the first coloumn and for the second column I can write :
and it goes the same till end...
I tried to write it in one for loop like the following but it gave me an error:
error : Subscript indices must either be real positive integers or logicals.
thanks for the help
Weitere Antworten (1)
Steven Lord am 24 Okt. 2019
Bearbeitet: Steven Lord am 24 Okt. 2019
reshape your vector to be 13-by-8 then take the transpose of it.
>> x = 1:104;
>> y = reshape(x, [13 8])
>> z = y.'
You can do this in one step, but I think it's important to see the intermediate result (y) so you can see how MATLAB arranges elements. This is useful knowledge for a technique called linear indexing.