update all array of the value

3 views (last 30 days)
vaya putra
vaya putra on 18 Jun 2022
Answered: Image Analyst on 18 Jun 2022
i have array 10000x1
my plan is to upadate all value into new value
a=old; %10000x1
b=new; % 10000x1
by using a=b;
i got problem for next calculation looks the new value duplicate many time then i got divergence calculation
i tried changed some value
example;
b(10)=10e-9;
b(11)=10e-9;
b(12)=10e-9;
b(13)=10e-9;
the calculation worked properly and the calculation did not multiple the new value
but i must update all value any idea
  4 Comments
Voss
Voss on 18 Jun 2022
@vaya putra: Not that this necessarily addresses your question, but note that 10e-9 means 10*10^-9, which is 10^-8 (i.e., 1e-8):
10e-9
ans = 1.0000e-08
vaya putra
vaya putra on 18 Jun 2022
Edited: vaya putra on 18 Jun 2022
i tried to changed in the particulary address i got the same problem in my calculation
a(3000) = b(3000)
...
...
a(8000) = b(8000)
but when change one by one with real number
a(3000)=9e-14;
a(3001)=9e-14;
....,...a(8000)=9e-14;
it worked
i dont know what the problem with my calculation

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 18 Jun 2022
When you do
a=old; %10000x1
b=new; % 10000x1
a=b;
a will now have the values of b and new. Then you said the problem is when you try to change a few specific values by doing:
b(10)=10e-9;
b(11)=10e-9;
b(12)=10e-9;
b(13)=10e-9;
Now this will change elements 10-13 of b but will NOT change those elements in new or a. Just because you did a=b does not mean that a is a pointer into the b locations of memory and that changing b should automatically change a simultaneously. If you want a to change you'll have to assign those elements of a explicitly.

More Answers (0)

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!