### MATLAB >> Question re: 'clipping' data

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

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
x(maxidx)=127*ones(length(maxidx),1);
minidx=find(x==0);
x(minidx)=127*ones(length(minidx),1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This snippet sets only the saturated samples to zero. It should be

Rune

### MATLAB >> Question re: 'clipping' data

No mex compiler available, unfortunately.....

Thanks!

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

```hello,
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
vmax
```

```Hi,
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

Iman
```

```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?

figure
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
x=16:0.1:25;
y=24*sin(x);
plot(x,y,'k-','linewidth',1.5);
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')
```

```How can i play my clip in matlab

How can i integrate a player in matlab

```