To plot an ellipse
古いコメントを表示
Hi,
I have got the semi axes, with that how to plot an ellipse in matlab. I have tried using the function 'pdeellip', but it didn't work out. Please do help.
Thanks in advance.
採用された回答
その他の回答 (1 件)
Waqar Khan
2021 年 3 月 18 日
0 投票
Hi there, I need help with creating ellipse, I have X = 0.666 and Y=0.87 values, I need to make ellipse from X and Y, kindly guide me. Looking forward to hearing from you.
10 件のコメント
Walter Roberson
2021 年 3 月 18 日
That is only a single point. There are an infinite number of different ellipses that pass through that point.
Waqar Khan
2021 年 3 月 18 日
Actually the X represent the length of major axis and the Y represent the length of minor axis. Can you guide me please with stepwise.
Walter Roberson
2021 年 3 月 18 日
There are still an infinite number of ellipses that can be used, since you have not indicated the center.
Use Image Analyst's code, https://www.mathworks.com/matlabcentral/answers/129273-to-plot-an-ellipse#comment_213506 with
xCenter = 0;
yCenter = 0;
xRadius = 2/3;
yRadius = 0.87;
Waqar Khan
2021 年 3 月 18 日
Thank you so much for sending the code link, yes because i dont have center values, just the X and Y mentioned. I did try the code you mentiond and i got the plot. Please find the attached.
Now i need to apply gaussain distribution on this, can you guide me about this please. Looking forward to your response.
Walter Roberson
2021 年 3 月 18 日
I don't know what it means to apply a Gaussian distribution to a plot.
Waqar Khan
2021 年 3 月 18 日
I means i want to apply Gaussain Distribution of sound amplitude on this ellipse. Is it clear now? can you guide me please.
Walter Roberson
2021 年 3 月 18 日
編集済み: Walter Roberson
2021 年 3 月 18 日
xCenter = 0;
yCenter = 0;
xRadius = 2/3;
yRadius = 0.87;
theta = linspace(0, 2*pi, 100);
%theta(end) = [];
x = xRadius * cos(theta) + xCenter;
y = yRadius * sin(theta) + yCenter;
xvec = linspace(min(x), max(x), 50);
yvec = linspace(min(y), max(y), 50) .';
h = fill(x, y, [0 0 .5], 'FaceAlpha', 0.3); axis equal; xlabel('x'); ylabel('y')
figure
P = 3;
G = 10*exp(-((xvec-xCenter).^2+(yvec-yCenter).^2)./P);
surf(xvec, yvec, G, 'edgecolor', 'none'); view(3); xlabel('x'); ylabel('y'); zlabel('G');
figure
d = sqrt(((xvec-xCenter)./xRadius).^2 + ((yvec-yCenter)./yRadius).^2);
d1 = d <= 1;
surf(xvec, yvec, double(d1), 'edgecolor', 'none'); axis equal; xlabel('x'); ylabel('y'); zlabel('Inside');
figure
G1 = G;
G1(~d1) = nan;
surf(xvec, yvec, G1, 'edgecolor', 'none'); xlabel('x'); ylabel('y'); zlabel('G');
Which is to say that the G matrix here is a gaussian based upon distance from a center, and that G1 is G masked so that everything outside the ellipse is nan. Possibly for your purpose it might make more sense to assign 0 to such places.
Waqar Khan
2021 年 3 月 18 日
thank you so much for the code and guidlines let me try it. Much thanks.
Walter Roberson
2021 年 3 月 18 日
Note: The P in the equation for G controls how quickly the Gaussian drops off. You should decide more carefully how much you want the gaussian to fall off by the edge of the ellipse.
Also note that what this implements is a circular guassian "clipped" by an ellipse. You could instead make the gaussian itself elliptical, by modifying distance from the center according to the ellipse parameter.
IIt is possible that what you need to do is construct an elliptical gaussian filter, such as for blurring purposes. You would proceed a bit differently in a case like that.
Waqar Khan
2021 年 3 月 18 日
Noted, Thank you so much once again, i am reading it carefully.
カテゴリ
ヘルプ センター および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





