image thumbnail

clip

version 1.0.0.0 (2.19 KB) by Chad Greene
Return the values of an array within a given range, optionally return corresponding clipped arrays.

1K Downloads

Updated 19 Aug 2013

View License

clip(x,xmin,xmax,varargin) returns a clipped or trimmed array containing only the values of x between xmin and xmax, inclusive. Inclusion of any other arrays as inputs returns corresponding clipped arrays. The optional argument 'exclusive' can be included to return only values between but not including xmin and xmax.

INPUTS AND OUTPUTS:

xclp = clip(x,xmin,xmax) returns an array of all values in x from xmin to xmax, inclusive.

xclp = clip(x,xmin,xmax,'exclusive') returns an array of all values in x from xmin to xmax, exclusive.

[xclp,ind] = clip(x,xmin,xmax) returns an array of all values in x from xmin to xmax, and also returns the indices of x corresponding to xclp. Note that xclp = x(ind).

[xclp,yclp] = clip(x,xmin,xmax,y) returns xclp and corresponding clipped values of the array y, which should be the same length as x.

[xclp,y1clp,y2clp,...,ynclp] = clip(x,xmin,xmax,y1,y2,...yn) returns clipped arrays of x and y1 through yn.

[xclp,y1clp,y2clp,...,ynclp,ind] = clip(x,xmin,xmax,y1,y2,...yn) returns clipped arrays of x and y1 through yn and corresponding indices ind. xclp = x(ind) and y1clp = y1(ind) and so on.

In the example image above, y1 through y4 were declared, and with an interest in values from x=70 to x=90, the clipped x and y arrays were found like this:

[xc,y1c,y2c,y3c,y4c] = clip(x,70,90,y1,y2,y3,y4);

Cite As

Chad Greene (2022). clip (https://www.mathworks.com/matlabcentral/fileexchange/43131-clip), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags
Acknowledgements

Inspired by: CLIP2

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!