Create a 2x2 matrix with column of values and zeros

30 ビュー (過去 30 日間)
Christopher
Christopher 2022 年 9 月 24 日
回答済み: Rohit 2022 年 9 月 27 日
Hi Guys,
So i'm experiencing a bit of difficulty in creating a temporary matrix, code below:
Positions = Postions'
Now, I would like to create a 2x2 matrix, with one column containg the transpose Position values and the other column to just be 0 for all the corresponding transpose values. Hope this makes sense.
  1 件のコメント
Image Analyst
Image Analyst 2022 年 9 月 24 日
Not really, not until you give an example.
If you have any more questions, then ask it after you read this:

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

回答 (1 件)

Rohit
Rohit 2022 年 9 月 27 日
Hello,
I understand that you are trying to create a 2*2 matrix with one column as “Positions” values and the second as all 0 values. Here, I am assuming the “Positions” to be an array [1 2]. Below code will create the required matrix:
Positions = [1 2];
col2 = zeros(2,1);
matrix = [Positions' col2]
matrix = 2×2
1 0 2 0

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by