필터 지우기
필터 지우기

How to create matrix with array under certain conditions?

조회 수: 1 (최근 30일)
Yun Inn
Yun Inn 2013년 5월 3일
I have an array:
A=[1.3 1.2 1.3]
How can I get matrix B using A?
B=[1.3 1.3 1.3; 1.3 1.2 1.3; 1.3 1.3 1.3]
Matrix B has the value of A at the central row,column,and diagonal.
  댓글 수: 1
José-Luis
José-Luis 2013년 5월 3일
You mean two diagonals? Otherwise two of the values of the resulting matrix are undefined.

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

채택된 답변

Chandrasekhar
Chandrasekhar 2013년 5월 3일
B = [ones(1,3)*A(1); A; ones(1,3)*A(1)]

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by