Updating values in a matrix when corresponding variable values are updated
Show older comments
In the code below, when a, a variable in matrix w, is updated the matrix does not automatically update. Is there a way to update it as a changes automatically?
a = 5;
w = [a 5 6]
a = 6
w
1 Comment
Stephen23
on 18 Nov 2021
No.
Answers (1)
You can do it with some object-oriented programming trickery, but in the long run, I don't think it's going to be what you want.
a=handleMatrix([15,1]) %handleMatrix is defined in the attachment.
w=[a,6 7 8]
a(1)=10;
w
Categories
Find more on Loops and Conditional Statements 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!