I does seem to me though that there is a bug when using this in combination with your pppiv-function.
In the function RobustWeights, there is a line:
MAD = median(abs(r(I)-median(r(I))));
However, the values of r are complex when using it together with pppiv. That causes the median function to sort the values by the real component and then take the middle value. I think you probably want to add
r = abs(r);
before taking the median to sort the residuals by magnitude instead. Is that correct?
sorry. Forget about my last comment. The reason it needed to be rotated is because I had this line of code.
set(figure1, 'PaperOrientation', 'landscape','PaperPositionMode','auto');
The paper orientation made it so I needed that rotation.
Thanks for the great submission.
This works great. Thank you.
One thing about this though. Using imread to read in the image rotates it left 90 degrees. I would suggest making one change to your script by adding imrotate like this
frame.cdata = imrotate(imread(tempfilename),-90);
This will rotate it back to the original orientation.