4x4 matrix with numbers from 1 to 4 in specific order
古いコメントを表示
Hi,
I want to create the following matrix:
M = 1 2 3 4
0 0 0 3
0 0 0 2
0 0 0 1
I'm only supposed to use the vector r = 1:4 and no other functions. This is what I got so far:
M=r
M(1:4, 4)=r
But this results in
M = 1 2 3 1
0 0 0 2
0 0 0 3
0 0 0 4
So now I'm stuck. Does anybody know how to "reverse" the last column so that it reads 4 3 2 1 instead of 1 2 3 4?
All help is greatly appeciated!
Cheers,
Dobs
採用された回答
その他の回答 (1 件)
John D'Errico
2021 年 10 月 23 日
編集済み: John D'Errico
2021 年 10 月 23 日
0 投票
Hint: What does flip do? Could you use it to "flip" the order of those numbers?
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!