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일

0 개 추천

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월 4일
no i meant there is
A = [4 5 7 9........1182 elements......]
i want B array as
B=[4 4 4(50 times)......5(50 times).......7(50 times).......]
B=repelem(A,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개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2021년 1월 4일

댓글:

2021년 1월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by