How to make one element in a matrix the same for other elements?
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Stephen23
on 1 May 2016
Edited: Stephen23
on 1 May 2016
>> 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
More Answers (1)
Roger Stafford
on 1 May 2016
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 Comments
See Also
Categories
Find more on Operating on Diagonal Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!