MATLAB - Convert vector to matrix
up vote
0
down vote
favorite
How could I convert vector in MATLAB to this specific type of matrix? Number of columns will be a parameter.
matlab
add a comment |
up vote
0
down vote
favorite
How could I convert vector in MATLAB to this specific type of matrix? Number of columns will be a parameter.
matlab
1
You want to reshape the vector?reshape
it then. Consider reading the documentation/using a search engine before asking in SO, basic "tutorial"-like questions are off topic
– Ander Biguri
Nov 7 at 11:21
it is not just a reshape since some values are duplicated.
– Brice
Nov 7 at 11:29
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
How could I convert vector in MATLAB to this specific type of matrix? Number of columns will be a parameter.
matlab
How could I convert vector in MATLAB to this specific type of matrix? Number of columns will be a parameter.
matlab
matlab
edited Nov 7 at 11:27
Wolfie
14.5k51741
14.5k51741
asked Nov 7 at 11:17
Matúš Prozbík
131
131
1
You want to reshape the vector?reshape
it then. Consider reading the documentation/using a search engine before asking in SO, basic "tutorial"-like questions are off topic
– Ander Biguri
Nov 7 at 11:21
it is not just a reshape since some values are duplicated.
– Brice
Nov 7 at 11:29
add a comment |
1
You want to reshape the vector?reshape
it then. Consider reading the documentation/using a search engine before asking in SO, basic "tutorial"-like questions are off topic
– Ander Biguri
Nov 7 at 11:21
it is not just a reshape since some values are duplicated.
– Brice
Nov 7 at 11:29
1
1
You want to reshape the vector?
reshape
it then. Consider reading the documentation/using a search engine before asking in SO, basic "tutorial"-like questions are off topic– Ander Biguri
Nov 7 at 11:21
You want to reshape the vector?
reshape
it then. Consider reading the documentation/using a search engine before asking in SO, basic "tutorial"-like questions are off topic– Ander Biguri
Nov 7 at 11:21
it is not just a reshape since some values are duplicated.
– Brice
Nov 7 at 11:29
it is not just a reshape since some values are duplicated.
– Brice
Nov 7 at 11:29
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You can build (once for all) a matrix with the indices (1:L on first column, 1:K on first row, etc), then simply do a selection from the data vector based on those indices
% matrix containing the indices
indices = bsxfun(@plus,(0:L-1)',(0:K-1)) + 1; % L-by-K matrix
% now get the data from the vector, based on the indices
X=x(indices);
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can build (once for all) a matrix with the indices (1:L on first column, 1:K on first row, etc), then simply do a selection from the data vector based on those indices
% matrix containing the indices
indices = bsxfun(@plus,(0:L-1)',(0:K-1)) + 1; % L-by-K matrix
% now get the data from the vector, based on the indices
X=x(indices);
add a comment |
up vote
1
down vote
accepted
You can build (once for all) a matrix with the indices (1:L on first column, 1:K on first row, etc), then simply do a selection from the data vector based on those indices
% matrix containing the indices
indices = bsxfun(@plus,(0:L-1)',(0:K-1)) + 1; % L-by-K matrix
% now get the data from the vector, based on the indices
X=x(indices);
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can build (once for all) a matrix with the indices (1:L on first column, 1:K on first row, etc), then simply do a selection from the data vector based on those indices
% matrix containing the indices
indices = bsxfun(@plus,(0:L-1)',(0:K-1)) + 1; % L-by-K matrix
% now get the data from the vector, based on the indices
X=x(indices);
You can build (once for all) a matrix with the indices (1:L on first column, 1:K on first row, etc), then simply do a selection from the data vector based on those indices
% matrix containing the indices
indices = bsxfun(@plus,(0:L-1)',(0:K-1)) + 1; % L-by-K matrix
% now get the data from the vector, based on the indices
X=x(indices);
answered Nov 7 at 11:28
Brice
7366
7366
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53188420%2fmatlab-convert-vector-to-matrix%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You want to reshape the vector?
reshape
it then. Consider reading the documentation/using a search engine before asking in SO, basic "tutorial"-like questions are off topic– Ander Biguri
Nov 7 at 11:21
it is not just a reshape since some values are duplicated.
– Brice
Nov 7 at 11:29