How to modify array in modifying subarray reference ?
Show older comments
Hello,
I would like to be able to modify an array in modifying a subarray. For example, I have these 3 arrays :
a = [1; 2];
b = [3 5; 4 6];
c = [a b];
When I modify a column of b,
b(:,1) = [6 8];
I would like that c changes too and becomes : [1 6 5; 2 8 6]. Whereas currently c remains [1 3 5; 2 4 6]...
How can I do that ?
Accepted Answer
More Answers (1)
Saurav Roy
on 28 Apr 2020
1 vote
Hi....
I am not sure I understood your question properly but I wrote something as per my initial understanding to get your results.
a = [1; 2];
b = [3 5; 4 6];
b(:,1) = [6 8];
c = [a b];
disp(c);
1 Comment
Clément T
on 28 Apr 2020
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!