Speeding up large array element access/modification in class
Show older comments
Hi all,
So I have a class and one of its properties is an array which is initialised to:
large_array = zeros(1,1000000);
I also have a method in the class:
function log(this)
this.large_array(1,this.current_iteration) = this.some_value;
end
My problem is this method which updates a value in the array per iteration takes AGES (89.9% of the total program time). I am already preallocating the array so I do not understand why it is taking so long. So my questions are:
Why is this taking so long?
How can I speed the accessing/modifying up?
Thanks for your time, Richy
Answers (1)
Richard
on 24 Mar 2011
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!