Insert an identity matrix into a larger dimension of null matrix

조회 수: 5 (최근 30일)
hellow everyone ! Suppose i have an identity matrix .
I=eye(3) which will produce
I = [1 0 0
0 1 0
0 0 1]
Now i want to insert I into a (5X5) null matrix such that my result will be
N = [0 0 0 0 0
0 0 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1]
How could i achieve this efficiently .Thanks in advace

채택된 답변

Rick Rosson
Rick Rosson 2014년 9월 7일
N = diag([0 0 1 1 1])

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by