Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After your update it seems like you will be able to 'correct the errors' by yourself. That only leaves the question of how to find them. However, I have also included a suggestion on how to interpolate a value and use this.</p> <p><strong>Finding the errors</strong></p> <p>Assuming this is your matrix:</p> <pre><code>x = [1 2 3 4 5; 2 3 2 5 6; 3 4 5 6 7; 4 5 6 7 8] </code></pre> <p>Assuming you have a vertically and horizontally increasing matrix, here is how to find anomalies:</p> <pre><code>idx = [zeros(1,size(x,2)); diff(x)&lt;0] | [zeros(size(x,1),1), diff(x,[],2)&lt;0] </code></pre> <p>If you want to have the row and column indices, you can do this:</p> <pre><code>[myRows, myCols] = find(idx) </code></pre> <p>If you are looking at a decresing pattern vertically, you can use <code>diff(x)&lt;0</code> for example. If you are looking for an exact difference (always one?) you can check whether the difference is equal to your value, but you will need to be aware of the dangers incurred by floating point calculations and rounding issues.</p> <p><strong>Filling the errors</strong></p> <p>My suggestion for you would be to first determine for each value, what the <code>backup</code> value is in case you want to replace it. This can be done by applying a filter for example:</p> <pre><code>altValues = filter2([0 1 0;1 0 1; 0 1 0]/4,x); </code></pre> <p>Now replacing the found errors can be done like this:</p> <pre><code>x(idx) = altValues(idx); </code></pre> <p>This will give the following result:</p> <pre><code> 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 </code></pre> <p>If you want to consider the diagonal differences, you may want to use this filter instead:</p> <pre><code>altValues = filter2(ones(3)/9,x); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload