How can I avoid using a for loop

y =[10;12;16;23;17;14;11;19;20;22;27;30;34;37;33;36;12;13;14;25;27;29;25;26];
N = 4;
n = 4;
for k = 1:1:n;
a(k) = N*(k-1)+ (2*k -1);
b(k) = N*k + 2*k;
yp(:,k) = y(a(k):b(k));
end
yy = yp

回答 (1 件)

Cedric
Cedric 2013 年 3 月 19 日
編集済み: Cedric 2013 年 3 月 19 日

0 投票

yy2 = reshape(y, [], 4) ;
I named it yy2 so you can compare with your yy.

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

タグ

質問済み:

2013 年 3 月 19 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by