how to create an array of ones with some zeros delimited by an ellipse?

조회 수: 2 (최근 30일)
Ricardo Souza
Ricardo Souza 2021년 8월 3일
댓글: Ricardo Souza 2021년 8월 9일
I need to create an array with ones inside an ellipse and zeros outside it. The matrix has dimensions of NxM = 91x361. This matrix will be plotted polarly and the ellipse must be completely contained within the matrix.
  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 8월 3일
One approach is to use an Ellipse ROI object https://www.mathworks.com/help/images/ref/images.roi.ellipse.html and createMask() from it.
This has the advantage of being fairly customizable as to center and axes lengths.
It is, though, overly complicated if you just happen to have the simple case of the ellipse being aligned with the x y planes.
Do you happen to be looking for the largest x y aligned ellipse that will fit completely inside your N x M ?

댓글을 달려면 로그인하십시오.

답변 (1개)

Rik
Rik 2021년 8월 3일
I'm going to ignore the part where you want to plot a cartesian object with polar coordinates.
You can either use ndgrid or meshgrid to generate a coordinate grid. Then you need to google the equation for an ellipse, after which it should be obvious how to adjust it to return all points inside the ellipse, instead of only the points exactly on the array.
To satisfy your requirement of each pixel being entirely inside the ellipse you can use the corners of each pixel and mark only the pixels if all four corners are inside.
Feel free to post a follow-up question in a comment if your have trouble implementing a specific step.
  댓글 수: 4
Ricardo Souza
Ricardo Souza 2021년 8월 9일
You got the same result as mine. What I want is to plot an ellipse in polar coordinates, which will appear in the four quadrants and will be a matrix where the 0<theta<90 and 0<phi<360. I need to plot in polar form. When you plot your figure in polar form something other than an ellipse will appear. Finally, I want a matrix (0<theta<90 and 0<phi<360), which plots in polar an ellipse centered anywhere and appearing anywhere within the matrix boundary.
Ricardo Souza
Ricardo Souza 2021년 8월 9일
the first image is my matrix (0<theta<90 and 0<phi<360) and the second is its respective polar plot. I need the description of the first matrix in its limits so that I can plot the second one.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by