How can I create following matrix using code

5 ビュー (過去 30 日間)
nabin
nabin 2014 年 5 月 8 日
コメント済み: Walter Roberson 2014 年 5 月 8 日
How can I create following matrix using code (as I have to create a large matrix of similar nature):
A_1= [1 1 1; 0 0 0; 0 0 0]
A_2= [0 0 0; 1 1 1; 0 0 0]
A_3=[0 0 0; 0 0 0; 1 1 1]
For A_1 the first row is 1 and rest are zero. For A_2 second row is 1 and other are 0. For A_3 third row is 1 and rest 0.

回答 (1 件)

Youssef  Khmou
Youssef Khmou 2014 年 5 月 8 日
try :
N=3;
A1=[ones(1,N);zeros(2,N)];
A2=[zeros(1,N);ones(1,N);zeros(1,N)];
A3=[zeros(2,N);ones(1,N)];

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by