Old Nick
Advanced Member level 1
![Advanced Member level 1](/styles/images/ranks/glevel1.gif)
Hi,
I'm accessing part of an array and averaging it using the following command.
sum(sum(phaseplot(30:60,35:65)))/(60-30)*(65-35)
The array is the phase of a signal modulated light camera. the above code averages the block I want to look at well, however if the light is at a phase of 170 degrees a 11 deg reading error on a pixel can show up as -179 degrees.
So what I want to do is detect these wrap-arounds and either add or subtract 360 to the offending elements, then average again.
Currently my thinking is to average, then loop through the (area of interest of the) array and detecting anything that is greater than 180 deg. away from the averaged value (although the average value will be skewed in one direction if any of these are present).
So my first question is,
How do I loop through an array and perform this check, (I would use a for loop if I was programming in C, but I would guess there is an easier way of doing this in matlab.)
second question is,
can anyone think of a better way of correcting these wrap-arounds?
I'm accessing part of an array and averaging it using the following command.
sum(sum(phaseplot(30:60,35:65)))/(60-30)*(65-35)
The array is the phase of a signal modulated light camera. the above code averages the block I want to look at well, however if the light is at a phase of 170 degrees a 11 deg reading error on a pixel can show up as -179 degrees.
So what I want to do is detect these wrap-arounds and either add or subtract 360 to the offending elements, then average again.
Currently my thinking is to average, then loop through the (area of interest of the) array and detecting anything that is greater than 180 deg. away from the averaged value (although the average value will be skewed in one direction if any of these are present).
So my first question is,
How do I loop through an array and perform this check, (I would use a for loop if I was programming in C, but I would guess there is an easier way of doing this in matlab.)
second question is,
can anyone think of a better way of correcting these wrap-arounds?