Updating values in a matrix when corresponding variable values are updated

조회 수: 5 (최근 30일)
Aleem Andrew
Aleem Andrew 2021년 11월 18일
편집: Matt J 2021년 11월 18일
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개)

Matt J
Matt J 2021년 11월 18일
편집: Matt J 2021년 11월 18일
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.
a =
15 1
w=[a,6 7 8]
w =
15 1 6 7 8
a(1)=10;
w
w =
10 1 6 7 8

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by