only one answer for for loop

1 回表示 (過去 30 日間)
Abhijit Sardar
Abhijit Sardar 2021 年 1 月 4 日
コメント済み: Matt J 2021 年 1 月 5 日
i have i*1182 an array A.i want make another array such every single element of the array A is printed 50 times so that i will another array with length of 1182*50 = 59100
for w = 1:1182
z = repmat(ult(w),1,50);
end
ult is 1*1182 array

採用された回答

Matt J
Matt J 2021 年 1 月 4 日
編集済み: Matt J 2021 年 1 月 4 日
This should really be done without a for-loop,
z = repmat(ult(:),1,50);
But if you insist on using a for-loop, you must tell the code where in z the result of each iteration is to be assigned,
for w = 1:1182
z(w,:) = repmat(ult(w),1,50);
end
  4 件のコメント
Abhijit Sardar
Abhijit Sardar 2021 年 1 月 5 日
thanks this really simplified everything
Matt J
Matt J 2021 年 1 月 5 日
You're quite welcome, but please Accept-click the answer to indicate that your problem was resolved.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by