How can I change values in my matrix according to conditions.
1 view (last 30 days)
Show older comments
Hannah Pickering
on 7 Feb 2017
Answered: Chad Greene
on 7 Feb 2017
I have a zeros(size,size) matrix that i want the values to change depending on my conditions. I have two conditions:
Support = FixedFixed or Support = PinnedPinned
When Support = FixedFixed my matrix coordinates should be
a(1,1) = 7;
a(1,2) = -4;
a(1,3) = 1;
a(size,size-2)=1;
a(size,size-1)=-4;
a(size,size)=7;
and when Support = PinnedPinned my matrix should be
a(1,1) = 5;
a(1,2) = -4;
a(1,3) = 1;
a(size,size-2)=1;
a(size,size-1)=-4;
a(size,size)=5;
can anyone help me code this?
0 Comments
Accepted Answer
Chad Greene
on 7 Feb 2017
switch SupportType
case 'PinnedPinned'
a(1,1) = 5;
a(1,2) = -4;
a(1,3) = 1;
a(size,size-2)=1;
a(size,size-1)=-4;
a(size,size)=5;
case 'FixedFixed'
a(1,1) = 7;
a(1,2) = -4;
a(1,3) = 1;
a(size,size-2)=1;
a(size,size-1)=-4;
a(size,size)=7;
end
0 Comments
More Answers (0)
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!