필터 지우기
필터 지우기

problem in inserting a diagnol

조회 수: 1 (최근 30일)
k.v.swamy
k.v.swamy 2012년 7월 12일
hi, i have a problem in inserting the diagnol of a matrix. i have a=[1 2 3;4 5 6;7 8 9] in which i have to extract the diagnol by multiplying with 2 and i want to again insert the diagnol i,e iwant to have [2 2 3;4 10 6;7 8 18]; i dont want to use the loop.
  댓글 수: 3
Yash
Yash 2012년 7월 12일
how do u want the output to be
San
San 2012년 7월 12일
he want to have double for diagonal but don't want loop :(

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

답변 (1개)

Conrad
Conrad 2012년 7월 12일
A = [ 1 2 3;...
4 5 6;...
7 8 9];
A(1:(length(A)+1):numel(A)) = 2*diag(A);

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by