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!