필터 지우기
필터 지우기

Multiplication of matrix with It's Diagonal Element to It's Row

조회 수: 2 (최근 30일)
I Have this below matrix.
z=[a11 a12 a13;
b21 b22 b23;
c31 c32 c33]
I want out put of the Matrix like this.
q=[1 -(a12/a11) -(a13/a11);
(-b21/b22) 1 (-b23/b22);
(-c31/c33) (-c32/c33) 1]
Can you please send me program for this Matrix operation.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 15일
편집: Azzi Abdelmalek 2014년 2월 15일
a=[1 2 3;4 5 6;7 8 9]
out=bsxfun(@rdivide, -a,diag(a))
out(sub2ind(size(a),1:size(a,1),1:size(a,1)))=1
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2014년 2월 15일
You should precise that.
m=tf(1,1:2)
a=[m m*2;1+m 5*m+2] % Example
%-------------------------
b=repmat(tf(1,1),size(a))
for k=1:size(a,1)
b(k,:)=-a(k,:)/a(k,k)
b(k,k)=1
end
CHANDRA SHEKHAR BESTA
CHANDRA SHEKHAR BESTA 2014년 2월 15일
편집: CHANDRA SHEKHAR BESTA 2014년 2월 15일
clc
K=[1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16];
L=[1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16];
T=[1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16];
one=[1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16];
n=4;
for i=1:n
for j=1:n
d{i,j}=tf([K(i,j)],[T(i,j) one(i,j)], [L(i,j)]);
end
end
a=d
%d = 4x4 Matrix with Transfer Function elements
out=bsxfun(@rdivide, -a,diag(a))
%above command giving error
out(sub2ind(size(a),1:size(a,1),1:size(a,1)))=1

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by