Creating Matrix Using Existing Matrix

조회 수: 10 (최근 30일)
Julian
Julian 2015년 10월 6일
답변: Julian 2015년 10월 6일
Hi, How do you create a matrix (not just a plot) that is a horizontal shear of a 2x2 identity matrix? For example, how do you create A=[1 2 ; 0 1] (identity horizontally sheared by 2)? Inputting the entries directly (A=[1 2 ; 0 1]) is not an answer that I'm looking for.
Thank you.

채택된 답변

Walter Roberson
Walter Roberson 2015년 10월 6일
SheerFactor = 2;
sheermat = eye(2);
sheermat(1,2) = SheerFactor;

추가 답변 (2개)

Andrei Bobrov
Andrei Bobrov 2015년 10월 6일
n - size matrix
full(spdiags(ones(n,1)*(0:2*n-1),1-n:n-1,n,n))
or
rot90(hankel(0:n-1,n-1:2*n-2))

Julian
Julian 2015년 10월 6일
Thank you all!

카테고리

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