필터 지우기
필터 지우기

update all array of the value

조회 수: 4 (최근 30일)
vaya putra
vaya putra 2022년 6월 18일
답변: Image Analyst 2022년 6월 18일
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