Troubleshooting my code ( ~15 lines)

2 Ansichten (letzte 30 Tage)
Vidhan Malik
Vidhan Malik am 23 Mär. 2016
Kommentiert: Vidhan Malik am 24 Mär. 2016
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.
  1 Kommentar
Walter Roberson
Walter Roberson am 24 Mär. 2016
Why do you sometimes access Cv with one index and sometimes access it with two indices?
Cv(i,2) = Cv(i-1) + 0.01;

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Star Strider
Star Strider am 23 Mär. 2016
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.
  26 Kommentare
Star Strider
Star Strider am 24 Mär. 2016
It’s relatively esoteric physiology and biochemistry, likely on par with the detailed fluid dynamics of jet engines. The point is that there are a lot of components to physiological regulatory systems, not all of which are even known, and most of which are important but are both uncontrollable and unobservable, at least in real time.
Vidhan Malik
Vidhan Malik am 24 Mär. 2016
Only until you figure it out! :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by