MATLAB: Trying to make the Implicit Function Work

equationsfiguresfunctionsimplicitimplicit functionsMATLABplottingvectors

I'm trying to plot an implicit function but it keeps returning that it behaves unexpectedly on array inputs. I don't know that I'm doing wrong because my Parts all all vectors as well as my plotting variables.
%All known or base variables%
Xc = [];
Yc = [];
e = 5.194469088;
f = 5.193588373;
a1 = 5.2548;
a4 = 0.2271;
fi2 = 1.046746555;
%All substitute value variables%
P1 = 2 * Xc * f;
P2 = e * cos(fi2);
Q1 = 2 * Yc * f;
Q2 = -e * sin(fi2);
R1 = Xc.^2 + Yc.^2 + f^2 - a1^2;
R2 = Xc -a4;
%Equation Parts%
Part1 = (R1 * Q2) - (R2 * Q1);
Part2 = (P1 * R2) - (P2 * R1);
Part3 = (P1 * Q2) - (P2 * Q1);
%Equation and Plot%
eq = @(Xc,Yc) (Part1.^2 + Part2.^2 - Part3.^2);
figure;
fimplicit (eq,[-100 100 -100 100]);

Best Answer

I'm going to walk through your code and comment on a few things along the way.
%All known or base variables%
Xc = [];
Yc = [];
e = 5.194469088;
f = 5.193588373;
a1 = 5.2548;
a4 = 0.2271;
fi2 = 1.046746555;
%All substitute value variables%
P1 = 2 * Xc * f;
Because Xc is empty so is P1. P1 is not a function of Xc or anything like that. If it were a function of Xc it would be something like:
P1 = @(Xc) 2*Xc*f;
Continuing on with your code:
P2 = e * cos(fi2);
Q1 = 2 * Yc * f;
Q1 is empty for the same reason P1 is except for Yc instead of Xc.
Q2 = -e * sin(fi2);
R1 = Xc.^2 + Yc.^2 + f^2 - a1^2;
R2 = Xc -a4;
R1 and R2 are empty because they're also functions of the empty matrix Xc. An empty plus or minus a scalar is still empty by scalar "expansion".
%Equation Parts%
Part1 = (R1 * Q2) - (R2 * Q1);
Part2 = (P1 * R2) - (P2 * R1);
Part3 = (P1 * Q2) - (P2 * Q1);
Each of these three parts is also empty.
%Equation and Plot%
eq = @(Xc,Yc) (Part1.^2 + Part2.^2 - Part3.^2);
So your "function of Xc and Yc" actually doesn't depend on the inputs Xc and Yc at all. It returns the sum and difference of three empty matrices, which means a simpler way of writing eq is:
eq = @(~, ~) [];
So when you call fimplicit:
figure;
fimplicit (eq,[-100 100 -100 100]);
It passes in something nonempty and receives an empty back. That's why it issues the warning.
You probably want to make Part1, Part2, and Part3 functions of Xc and Yc, which will require making the P#, Q#, and R# lines into functions like I did with P1 (and calling them as functions rather than referring to them as variables.)