필터 지우기
필터 지우기

Troubleshooting my code ( ~15 lines)

조회 수: 3 (최근 30일)
Vidhan Malik
Vidhan Malik 2016년 3월 23일
댓글: Vidhan Malik 2016년 3월 24일
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
Walter Roberson
Walter Roberson 2016년 3월 24일
Why do you sometimes access Cv with one index and sometimes access it with two indices?
Cv(i,2) = Cv(i-1) + 0.01;

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2016년 3월 23일
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
Star Strider
Star Strider 2016년 3월 24일
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 2016년 3월 24일
Only until you figure it out! :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by