I don't recognize that form of the equation for an ellipse but if you use want an ellipse you could do something like this. The function ellipse can take either
2 inputs - a, b
3 inputs - a, b, theta
4 inputs - a, b, x0, y0
5 inputs - a, b, x0, y0, theta
where theta is in degrees.
the only non-common functions are flip
which flips the vectors and nargin
which allows for the variable number of inputs.
x0 = -5;
y0 = 3;
a = 2;
b = 1;
theta = 7.5;
[x, y] = ellipse(a, b, x0, y0, theta);
plot(x, y)
axis equal
function [x,y] = ellipse(a, b, x0, y0, theta)
if nargin < 2
disp('Please enter at least the semi-major and -minor axis')
elseif nargin == 2
x0 = 0;
y0 = 0;
theta = 0;
elseif nargin == 3
theta = x0;
x0 = 0;
y0 = 0;
elseif nargin == 4
theta = 0;
elseif nargin ~= 5
disp('Too many input arguements')
end
X = linspace(-a, a, 100);
Y = [b*sqrt(1 - (X/a).^2), -b*sqrt(1 - (flip(X)/a).^2)];
X = [X, flip(X)];
x = X * cosd(theta) - Y * sind(theta) - y0;
y = X * sind(theta) + Y * cosd(theta) - x0;
end