How can I create a simple matrix of 4 by 4 using a "for" loop. to make a diagnol of 1's starting from top right to bottom left?
이전 댓글 표시
Not sure where to start this is my second time using MATLAB, thanks!
댓글 수: 1
Jan
2013년 1월 24일
Please try it. What are the indices of the 1s?
답변 (3개)
Walter Roberson
2013년 1월 24일
1 개 추천
Hint: the indices sum to 5.
댓글 수: 1
Jan
2013년 1월 24일
+1: This is no solution of a homework question.
Michael Joslin
2013년 1월 24일
편집: Michael Joslin
2013년 1월 24일
0 개 추천
Heres a way to do it without a for loop if your interested:
a = ones(4); a = diag(diag(a)); rot90(a)
This might not be too helpful if all of your other elements are not zero.
Sean de Wolski
2013년 1월 24일
편집: Sean de Wolski
2013년 1월 24일
I = fliplr(eye(4));
댓글 수: 2
Walter Roberson
2013년 1월 24일
This does not go top right to bottom left.
Sean de Wolski
2013년 1월 24일
fixed
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!