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!