![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/194323/image.jpeg)
Plot an ellipse,whose length of major axis (a), length of minor axis (b) and center (h,k) in the domain of x->[0,1] in MATLAB
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Math Enthusiast
el 7 de Nov. de 2018
Comentada: madhan ravi
el 7 de Nov. de 2018
Hi,
I want to know,if there is any direct function inorder to plot an Ellipse,which has its length of major axis as "a", length of minor axis as "b" and center (h,k) in the domain of x->[0,1].
Thanks in Advance!
0 comentarios
Respuesta aceptada
Dimitris Kalogiros
el 7 de Nov. de 2018
I suggest the following script :
clearvars; clc; close all;
syms x y a b h k
% ellipse axis
a=2; b=1;
%ellipse center
h=1; k=0;
%ellipse equation
ellipse= (((x-h)^2)/(a^2))+(((y-k)^2)/(b^2))==1;
%plot the ellipse
plotZoom=(max(a,b)+max(abs(h), abs(k)))+1;
fimplicit(ellipse, [-plotZoom plotZoom]);hold on;
plot([-plotZoom plotZoom], [0 0], '-k');
plot([0 0 ], [-plotZoom plotZoom], '-k');
plot(h, k, 'b*');
xlabel('x'); ylabel('y');
grid on; zoom on;
In case you execute it , you will get this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/194323/image.jpeg)
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Exploration en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!