Selecting data within a particular shape from a matrix.

7 views (last 30 days)
I want to select data around point [169,547] in the attached v variable. Attached is the figure of the shape in which I want the coordinate values, their distance and angle with respect to the center point [169,547]. The case represents a dynamic crack which moves forward in the next frame and thus the center position will change in the next frame and the whole process will be repeated again. Any guidance regarding the implementation would be great.
Matt J
Matt J on 22 Jul 2020
waqas commented:
I started a new question which is on the same lines as this question. It would be interesting to hear from you guys about that! I tried to figure it out by my own but am unable to get exactly what I want to.

Sign in to comment.

Accepted Answer

Matt J
Matt J on 31 Aug 2019
Edited: Matt J on 31 Aug 2019
As an example,
xc=547; yc=169; %center coordinates
rint=10; rext=50; %internal and external radii
[X,Y]=meshgrid((1:size(v,2))-xc, (1:size(v,1))-yc );
crack= Y<=rint & Y>=-rint & X<=sqrt(rint^2-Y.^2);
region= X.^2+Y.^2<=rext^2 & ~crack;
selected_data = v(region);
waqas on 7 Oct 2019
Edited: waqas on 7 Oct 2019
Thank you so much for your input. It works perfectly. Just one correction, change the position of rho and theta in both cart2pol and pol2cart just in case someone comes across same problem in future.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!