フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can i convert 160by1 column vector into 16by145 such that first column contain 1 to 16 and second column 2 to 17 and so on?

1 回表示 (過去 30 日間)
rajesh kumar
rajesh kumar 2020 年 5 月 30 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
i have 160x1 column vector. i have to convert that into matrix form such that first column contain 1 to 16 and second coulumn contain 2 to 17 and so on

回答 (2 件)

Alejandro Peñuelas
Alejandro Peñuelas 2020 年 5 月 30 日
編集済み: Alejandro Peñuelas 2020 年 5 月 30 日
With a for loop you can iterate over the index you want to start each row of the new matrix. Something like this:
% Original vector
vec = (1:160)';
% Matrix creation
mat = zeros(145, 16);
rowSize = 16;
for i = 1:145
mat(i,:) = i:i+rowSize-1;
end
% Transpose the new matrix
mat = mat';
The '-1' is to avoid the overflow of the indexes.
Hope this help you.

Walter Roberson
Walter Roberson 2020 年 5 月 30 日
If you have the communications toolbox, then you can use
temp = buffer(YourVector, 16, 15);
out = temp(:,16:end);

この質問は閉じられています。

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by