Reshape the vector as indexed matrix.

1 回表示 (過去 30 日間)
Sangeetha R
Sangeetha R 2020 年 3 月 6 日
編集済み: Sangeetha R 2020 年 3 月 10 日
I need to reshape each row vector in 'x' to the 2D matrix as indexed in 'idx'. I have written the code and working fine. But it takes more time as the number of rows in x is high. Is there any way to reduce the execution time?
x=ones(4732,28000);
idx = buffer(1:28000,10,5,'nodelay');
tic
for i=1:4732
x1=x(i,:);
y=x1(idx);
end
toc
Elapsed time is 1.450427 seconds.

回答 (1 件)

Alex Mcaulley
Alex Mcaulley 2020 年 3 月 6 日
Yes, just removing the for loop because this loop doesn't do anything in your code.

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by