필터 지우기
필터 지우기

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

조회 수: 2 (최근 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 CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by