How to make one element in a matrix the same for other elements?
조회 수: 1 (최근 30일)
이전 댓글 표시
What I mean by the question is the following:
Say I have matrix A and my A(2,1) = constant
Is there a way that I can write A(2,1)=A(2,1)=A(2,3) and so on?
댓글 수: 2
채택된 답변
Stephen23
2016년 5월 1일
편집: Stephen23
2016년 5월 1일
>> x = 1;
>> y = 2;
>> N = 4; % size of the matrix
>> A = eye(N) * x;
>> A(1+1:1+N:end) = y;
>> A(1+N:1+N:end) = y;
>> A(1) = 8;
>> A(end) = 10
A =
8 2 0 0
2 1 2 0
0 2 1 2
0 0 2 10
추가 답변 (1개)
Roger Stafford
2016년 5월 1일
You want every other element in the second row to be set equal to the first element?
A(2,:) = A(2.1);
Or do you have other elements to be set? Your description is not very clear.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!