update all array of the value

4 次查看(过去 30 天)
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 个评论
Voss
Voss 2022-6-18
@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 2022-6-18
编辑:vaya putra 2022-6-18
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

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2022-6-18
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by