variable=variable+i written something like variable+=i?

I have an array with a long calculation as index and want to add 1*(the imaginary unit) to that element in the array and I would like to do that without writing it twice, how do I do that?

답변 (2개)

Guillaume
Guillaume 2014년 10월 8일

0 개 추천

There's nothing equivalent to the operator += in matlab. There is no way round to writing the variable name twice, I'm afraid.
Thorsten
Thorsten 2014년 10월 8일
You can us something like this so that you don't have to do the very long index computation twice
ind = % very long computation here
array(ind) = array(ind) + sqrt(-1);

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2014년 10월 8일

답변:

2014년 10월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by