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

1 回表示 (過去 30 日間)
Emerson De Souza
Emerson De Souza 2011 年 8 月 30 日
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

採用された回答

Yoav Livneh
Yoav Livneh 2011 年 8 月 30 日
Use this:
ix=mod(V(:,1),2)==0 & mod(V(:,2),2)==0;
V_SKIP = V(ix,:);
  1 件のコメント
Emerson De Souza
Emerson De Souza 2011 年 8 月 30 日
Thank you Yoav,
this suggestion fixed the problem
Wish you a nice day
Emerson

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by