how to correctly skip elements of a vector field table with 4 columns

1 Ansicht (letzte 30 Tage)
INTRO: I have a vector field table build of 4 columns: the first two columns are the x and y coordinates, respectively and the last two columns are the x and y components, respectively. For instance, I created this vector field table with the command lines below:
%********************** CREATE XY COORDINATES ***********************
xvector = 1:1:10;
yvector = 1:1:10;
numX = numel(xvector);
numY = numel(yvector);
yvector = repmat(yvector(:),numX,1);
xvector = repmat(xvector ,numY,1);
XY_C = [xvector(:) yvector];
%********************** CREATE XY COMPONENTS ************************
a=(1:1:100);
x=2*a';
y=5*a';
%************************ VECTOR_FIELD TABLE ****************************
V=[XY_C x y];
%**************************************************************************
Thus, there are hundred pairs of coordinates and there is an associated x and y component for each pair.
GOAL:
Assume the vector field table is given from elsewhere but is similar as above.I want to build a new vector field table by excluding elements from the original table. To do so, I wrote the following lines:
%************************** EXCLUDE ELEMENTS ***************************
SKIP=2;
V_SKIP=V(0+SKIP:SKIP:end,:);
%**************************************************************************
RESULTS and PROBLEM: If you run the command lines above, you will see that the new vector field table has excluded elements only along the y-coordinate while the elements of the x-coordinates are all there.
INTENTION: I would appreciate if someone knows what I have to do to exclude the elements also along the x-coordinate. For the particular case above, the first 10 lines of the new table would be:
2 2 24 60
2 4 28 70
2 6 32 80
2 8 36 90
2 10 40 100
4 2 64 160
4 4 68 170
4 6 72 180
4 8 76 190
4 10 80 200
Thank you a lot in advance for help
Emerson

Akzeptierte Antwort

Yoav Livneh
Yoav Livneh am 30 Aug. 2011
Use this:
ix=mod(V(:,1),2)==0 & mod(V(:,2),2)==0;
V_SKIP = V(ix,:);

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by