Hello. I am trying to implement a progress par for a parfor loop, following the example shown at
I am using a script instead of a function as shown in the example, but I am unable to adapt the code in a way that works.
My code:
clearD = parallel.pool.DataQueue;h = waitbar(0, 'Please wait ...');afterEach(D, @nUpdateWaitbar);num_files = 1000;parfor i = 1:num_files % do stuff
send(D, [i num_files]);endfunction p = nUpdateWaitbar(input) p = input(1)/input(2) waitbar(p, h);end
Executing this gives
Warning: Unrecognized function or variable 'h'.
which I assume is because the function nUpdateWaitbar doesnt know what 'h' is
but if I try to pass the waitbar handle 'h' into the dataqueue, I get another error:
Cannot convert double value 1000 to a handle
Can you please point me towards what I am doing wrong?
the parfor loop runs fine without the waitbar code so I dont think that is the issue
thanks!
Best Answer