0
votes

I need to draw this:

![f=1 ( this is ellipse equation][1]

(2*X/(1+sgnX)*Rfoce-(1-sgnX)*Raft)^2+(2*Y/(1+sgnY)*Rstarb-(1-sgnY)*Rport)^2=1

sgnX=1 when X>=0
sgnX=-1 when X<0

-1*Raft=<X=<Rforce
-1*Rport=<Y<=Rstarp

How can I draw it? I tried, however, to draw another shape and not an ellipse. Could you please help me?

Rforce, Raft, Rstarb, Rport are the input parameters.

2
If you coded the formula as the one you posted it looks like you have a parenthesis problem. Please post your code if you want a precise answer.Ratbert

2 Answers

1
votes

You could use this:

ezplot('your ellipse equation'); grid on;

0
votes

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