MATLAB: Troubleshooting the code ( ~15 lines)

troubleshooting

I am using the following code:
syms B1 B2 SWR Cv
i = 1;
Cv(1,2) = 0.39;
B1(1,2) = 55;
B2(1,2) = 29;
while i<61
i = i + 1;
Cv(i,2)= Cv(i-1) + 0.01;
R = 0.5 == Cv(i,2)./2*(tan(B1*pi/180) + tan(B2*pi/180));
Cp = 0.5 == 1- (1+tan(B2*pi/180).^2)/(1+tan(B1*pi/180).^2);
[B1(i,2),B2(i,2)] = vpasolve([R, Cp], [B1,B2]);
SWR = Cv(i,2)*(tan(B1(i,2)*pi/180) - tan(B2(i,2)*pi/180));
X(i,2) = Cv(i,2);
Y(i,2) = SWR;
end
And it is giving me the following errors:
Warning: The system is inconsistent. Solution does not
exist.
> In symengine
In sym/privBinaryOp (line 908)
In / (line 309)
In gasturbine_hw7_try2 (line 16)
Error using sym.getEqnsVars>checkVariables (line 92)
The second argument must be a vector of symbolic
variables.
Error in sym.getEqnsVars (line 54)
checkVariables(vars);
Error in sym/vpasolve (line 132)
[eqns,vars] = sym.getEqnsVars(varargin{1:N});
Error in gasturbine_hw7_try2 (line 18)
[B1(i,2),B2(i,2)] = vpasolve([R, Cp], [B1,B2]);
I am having trouble understanding why the errors are occurring. What I am trying to do is solve equation R and Cp for increasing values of Cv. So I am simply making an array for the variables B1, B2 and Cv and using the values in each index to solve for a specific value of SWR. I know you can do this using anonymous functions, but I am having trouble doing it that way and so am doing it this way. I seek help in this method, not the other.

Best Answer

What was the problem with my fsolve approach? Using fsolve is much more efficient than using the Symbolic Math Toolbox for iterative problems.
Note that:
R = 0.5 == Cv(i,2)./2*(tan(B1*pi/180) + tan(B2*pi/180));
is equivalent to:
R = 0.5 == Cv(i,2)*(tan(B1*pi/180) + tan(B2*pi/180))./2;
You need to be sure your parentheses are nested correctly.