필터 지우기
필터 지우기

How to stack arrays into a matrix

조회 수: 13 (최근 30일)
France Poirier
France Poirier 2020년 12월 31일
답변: Walter Roberson 2020년 12월 31일
Hi,
This sounds like it should be really easy, but I can't figure out a way to do it without a loop. I want to avoid loops as I am working with large matrices and speed is important.
I have a 1xm array which I'd like to stack into a nxm matrix. Is there a quick and easy way to do it without a loop?
Thank you!
  댓글 수: 3
France Poirier
France Poirier 2020년 12월 31일
Thank you very much! Does exactly what I need
France Poirier
France Poirier 2020년 12월 31일
If you paste it inthe "Answer this question" section I could accept it...

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2020년 12월 31일
You have a (single) 1xm array? If you need it to be nxm then
repeated_matrix = repmat(TheArray, n, 1)
Side note: in current releases, repmat() is a built-in. In older versions, repmat() was a .m file that in this particular case would have come down to
repeated_matrix = TheArray(ones(n,1), :)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by