kakearney / plotboxpos-pkg

Return the position of the plotted region of a Matlab axis
MIT License
8 stars 1 forks source link

Faster processing #6

Open PUS234 opened 3 years ago

PUS234 commented 3 years ago

Dear Kelly,

'plotboxpos' works perfect for me. The problem for me is, it is for my purpose the bottleneck in respect to processing time. Two of the main time consuming statements are: temp = axes('Units', 'Pixels', 'Position', pos, 'Visible', 'off', 'parent', hparent); and delete(temp);

Both statement use about 60% of the processing time. Attached you will find a faster Version. It is about 5 times faster in Matlab R2016a and, surprise, 7 times faster in Matlab R2020a. Changes are only at the end of the code. May be you want to implement that changes in an updated version.

Best regards from Germany, Peter

plotboxpos.zip

PUS234 commented 3 years ago

the next largest processing load is on line 30: axisPos = getpixelposition(h);%Takes on my PC with 6000 runs 1.49 seconds

If you replace it by:

set(h,'units','Pixels'); axisPos = get(h,'Position'); set(h,'units',currunit);

you gain 30% of time . The three lines take with 6000 runs 1.04 seconds