get a diagonal line in matrix
    3 ビュー (過去 30 日間)
  
       古いコメントを表示
    
Hi, please help me get a diagonal line in matlab. Example, I have a matrix: a = [1 2 3; 4 5 6; 7 8 9] I want to get vector b =[3 5 7] which is a diagonal line of matrix a. This is my code but it doesn't work
 a=[1 2 3; 4 5 6; 7 8 9];
 b = zeros(1,3);
for i=1:3
    for i=1:3
       b = a(i,j);
    end
end
0 件のコメント
採用された回答
その他の回答 (1 件)
参考
カテゴリ
				Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

