MATLAB >> Question re: 'clipping' data

by Bill Blum » Sat, 17 Jul 2004 07:13:18 GMT

Okay, I have a question for the group:

I've got a A/D converter pulling data from one of our instruments, and
we're reading it in over the serial port.

The data is all 8-bit unsigned int, range 0-255 inclusive.... I'm
dealing with vectors that contain between 1 and 2 million samples total.

*However*, due to an issue in the A/D converter, we're getting repeated
'spikes', of sorts, about every 2000 samples.

If we subtract 127 from each element of the data vector (to recenter it
around zero), the meaningful part of the signal is generally confined
between +/- 50.

My question is this: is there an elegant, vectorized way of setting
any element outside that range to zero? Right now, we're doing the
brute-force forloop method, but we'd like to expand to 5 million data
points in the vector, and any time we save would be a benefit.

Thanks for your time, and replies to the group-- email address goes nowhere.

- Bill Blum, Wright State Univ.

MATLAB >> Question re: 'clipping' data

by allnor » Sat, 17 Jul 2004 18:05:11 GMT

I can think of two ways:

1) The memory-preserving way, which is to write a mex function in C or
FORTRAN that runs through the vector and replaces every instance of
0 and 255 with 127 (before subtracting 127 from the data). It would
take some time to code, but is probably the fastest method to run.

2) The matlab way:

maxidx=find(x==255); % x is the data column vector

This snippet sets only the saturated samples to zero. It should be
straightforward to adjust the FIND statements to your needs.


MATLAB >> Question re: 'clipping' data

by Bill Blum » Sat, 17 Jul 2004 21:49:27 GMT

No mex compiler available, unfortunately.....


That should help me clip the saturated points for now, until I get an
adaptive interpolator working to handle the outlying points.

( Most of my previous programming experience is in Java, I'm pretty much
learning MATLAB as I go )

- Bill Blum

Similar Threads

1. Question 'clipping' data - MATLAB

2. convert colour video clip to B/W video clip

i am doing a project on image processing. my first step in that is to convert this colour video clip in to B/W or Grayscale video clip.i am able to read the avifile in MATLAB. and i can display avifile. also, i can view all the frames in video clip.
so ,my questiion is how to convert the colour video clip in to grayscale or B/W videoclip?

with thanks and regards 

3. clipping of data - MATLAB

4. clipping all data located behind the camera position even when the data is seen from different point

I am using campos and camtarget to define the viewing axes and volume, whenever these these two properties are reset, the whole scene will be rotated and traslated in  the way that the viewing axis is perpendicular to the screen, and only the part of scene which is out of the view volume will be rendered, but when I rotate the scene, I can still see all of it. what I want is that whenever I rotate the scene, or look at it from top,  I only see the part which is infront the camera and clip  whatever located behind that  camera position.
Could any one help? thanks in advance


5. clip 3D surface according to X Y coordinate? - MATLAB

6. clipping probelm

I'm trying to a clipping region out of the axis region in Matlab 2009a, however, it does not work.  please see the code below. Does anyone know the reason?

hp=patch([18.4 24 24 18.4]/24+19,[-300 -300  25 25],[1 0  0]);set(hp,'facecolor',[1 0 0],'edgecolor','none');  hold on 
set(gca,'xlim',[16 21],'ylim',[-25 25],'ytick',[-25:5:25],'xgrid','on','ticklength',[0.020 0.025],'layer','top','box','on','Clipping','off')

7. Clipping 3D mesh Plot - MATLAB

8. I have a clip and want to play it in matlab

How can i play my clip in matlab

How can i integrate a player in matlab