I would recommend setting up a new channel. Then you can set a react to call a MATLAB analysis to write the data to the new channel. First create the new MATLAB analysis. I would read the last data point from the channel.
%now write to the new channel
Be sure to change the channel ID and the write API key.
Now create a new react and set the react to act on data entry for your first field, and make the criteria such that it will always be called (I like to use if field 1 value is not equal to 'fish'). Then select MATLAB Analysis as the action and choose the name of the MATLAB analysis you created.
Field 2 will show the number of times you got bad data, and field 1 will have the values you wanted.