MATLAB: Error when solve system of equation using vpasolver

vpasolver

function [BF1,BF2,BF3,BF4,CO,COreq] = solveBF(k,MaxBFvsk,PctBF,MuVO2,COmax,BF1,BF2,BF3,BF4,CO,COreq)
%UNTITLED5 Summary of this function goes here
% Detailed explanation goes here
syms BF1(k) BF2(k) BF3(k) BF4(k) CO(k) COreq(k)
eqn1 = BF3(k)-(0.012*CO(k)); %ml/min


eqn2 = BF1(k)-(0.92*CO(k)); %ml/min
eqn3 = BF4(k)-(MaxBFvsk*PctBF*1000); %ml/min
eqn4 = BF2(k)-((100*MuVO2)/(0.8*210));
eqn5 = COreq(k)-BF1(k)-BF2(k)-BF3(k)-BF4(k);
eqn6 = CO(k)-(0.5*(COreq(k)+COmax)); %ml/min CO=HRR*SV is another method
[BF1,BF2,BF3,BF4,CO,COreq] = vpasolve(eqn1,eqn2,eqn3,eqn4,eqn5,eqn6);
end
And the error says:
Error using sym/vpasolve (line 149)
Input with 1 variables and output with 6 variables are inconsistent.
Error in solveBF (line 20)
[BF1,BF2,BF3,BF4,CO,COreq] = vpasolve(eqn1,eqn2,eqn3,eqn4,eqn5,eqn6);
Error in test (line 159)
[BF1,BF2,BF3,BF4,CO,COreq] =
solveBF(k,MaxBFvsk,PctBF,MuVO2,COmax,BF1,BF2,BF3,BF4,CO,COreq);

Best Answer

The easiest way to find out what variables vpasolve is solving for is to re-write it as:
solution = vpasolve(eqn1,eqn2,eqn3,eqn4,eqn5,eqn6);
That will return the variables it finds, in the ‘solution’ structure. You can then see what they are.
Another possibility is to rewrite it as:
[BF1,BF2,BF3,BF4,CO,COreq] = vpasolve([eqn1,eqn2,eqn3,eqn4,eqn5,eqn6], [BF1,BF2,BF3,BF4,CO,COreq]);
See which one works best.
Related Question