Matrix Row Addition Question
1 回表示 (過去 30 日間)
古いコメントを表示
Good evening all!
I have a quick question. I am attempting to create the follow matrix in MATLAB:
0 0 0 0 0 0
0 0 0 0 0 0
0 0 8 6 4 2
I am completly new to MATLAB and I am just learning about matricies. My question is in regards to how do I create the last row? I was able to create the first two using the following command:
k= [zeros(2,6); ]
I would have used a linspacing command but those first two initial 0s prevent that. Thanks again for your help. I am just trying to honestly learn how to code in this language.
0 件のコメント
採用された回答
Star Strider
2019 年 4 月 19 日
There are several ways to do what you want.
Here’s one:
k = zeros(3,6);
k(end, 3:6) = 8 : -2 : 2;
2 件のコメント
Star Strider
2019 年 4 月 19 日
As always, my pleasure!
In one line:
k = [zeros(3,6); 0 0 8 : -2 : 2];
This is ‘vertical concatenation’.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!