How can I write a Matrix with different elements by typing in a single command?
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
I have a matrix of
[0 0 0 0 0; 0 0 1 10 20; 0 0 2 8 26; 0 0 3 6 32]
How can this be written in Matlab using a single command line.
1 件のコメント
Geoff Hayes
2018 年 4 月 19 日
Talal - why one line of code? The obvious is
A = [0 0 0 0 0; 0 0 1 10 20; 0 0 2 8 26; 0 0 3 6 32];
but I suspect that isn't what you had in mind since it isn't making use of the pattern in your non-zero block (+1,-2,+6). Are you trying to define a pattern and then generate a matrix from it?
回答 (1 件)
James Tursa
2018 年 4 月 19 日
By putting it all on one line:
[0 0 0 0 0; 0 0 1 10 20; 0 0 2 8 26; 0 0 3 6 32]
But why do you need it on one line? The multi-line version is more readable.
0 件のコメント
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!