필터 지우기
필터 지우기

Matrix in matlab equation

조회 수: 1 (최근 30일)
Amy Topaz
Amy Topaz 2022년 3월 12일
댓글: Amy Topaz 2022년 3월 12일
A = 1*1000 matrix
I need another matrix Y which has all the rows as A
Y = 1000*1000 matrix
How to do that??

채택된 답변

Torsten
Torsten 2022년 3월 12일
Y = repmat(A,1000,1)
  댓글 수: 2
Amy Topaz
Amy Topaz 2022년 3월 12일
Thank you
What about when Y has all columns as A?
Torsten
Torsten 2022년 3월 12일
편집: Torsten 2022년 3월 12일
My guess is that you mean
Y = repmat(A.',1,1000)
Since the columns of A have 1 element and those of Y have 1000 elements, Y cannot have all its columns as A.

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

추가 답변 (1개)

John D'Errico
John D'Errico 2022년 3월 12일
편집: John D'Errico 2022년 3월 12일
An alternative to repmat is to use a dot product (if you are an old APL person like me, then the phrase "outer product" will come to mind.) Thus, if A is a 1x1000 vector, then
B = ones(1000,1)*A;
B will be a matrix that has rows identical to A, with 1000 copies thereof.
Similarly, if you instead want columns that are copies of the row vector A, you can do this:
C= A.'*ones(1,1000);
C will be a 1000x1000 matrix, with columns given as A, and 1000 such columns.
Note my use of the .' operator there, since if you use the ' operator instead, then it will form the conjugate transpose if A had any complex or purely imaginary elements.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by