- #1
moouers
- 80
- 0
Homework Statement
Create the following matrix by typing one command. Do not type individual elements explicitly.
\begin{array}{ccc}
0 & 0 & 0 & 0 & 0 \\
0 & 0 & 1 & 4 & 7 \\
0 & 0 & 2 & 5 & 8 \\
0 & 0 & 3 & 6 & 9 \\ \end{array}
Homework Equations
None
The Attempt at a Solution
A previous problem was very similar, except the "1 2 3" etc elements were in a row rather than a column. For that problem, I came up with e(2:4,3:5)=[1:3;4:6;7:9] and it worked. For this problem, however, I can seem to only get it to work if I do it in more than one command, such as:
>> e(2:4,3)=[1:3],e(2:4,4)=[4:6],e(2:4,5)=[7:9]
I have no idea how to do this in one command. I tried the following but got the "Subscripted assignment dimension mismatch." error:
e(2:4,3:5)=[1:3,4:6,7:9]
I also tried transposing, but got nowhere fast. This isn't for a grade (self-teaching so the requirement can be waived as per agreement), but I need to become proficient at this program. Any help is greatly appreciated.