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
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
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 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!