How do I take a matrix of x,y values and insert in a value 1 in a square matrix? For instance in a Mat = 4 x 4 matrix of zeros and the matrix XY = (1,2) (3,4). How do I enter a 1 into (1,2) and (3,4)?

1 回表示 (過去 30 日間)
How do I take a matrix of x,y values and insert in a value 1 in a square matrix? For instance in a Mat = 4 x 4 matrix of zeros and the matrix XY = (1,2) (3,4). How do I enter a 1 into the positions (1,2) and (3,4)?

採用された回答

KSSV
KSSV 2018 年 6 月 14 日
編集済み: KSSV 2018 年 6 月 14 日
A = zeros(4) ;
A(1,2) = 1 ;
A(3,4) = 1 ;
Read about matlab matrix indexing.
  4 件のコメント
KSSV
KSSV 2018 年 6 月 14 日
I guess, you are working on FEM and you want to apply some boundary conditions at XY to given matrix A. is it?
MP
MP 2018 年 6 月 14 日
Thank you! That worked for me

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by