Filter löschen
Filter löschen

update all array of the value

4 Ansichten (letzte 30 Tage)
vaya putra
vaya putra am 18 Jun. 2022
Beantwortet: Image Analyst am 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 Kommentare
Voss
Voss am 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 am 18 Jun. 2022
Bearbeitet: vaya putra am 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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 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.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by