function variable = getVariableFromStateEquation(variableName, state, gas) stateHasSpecificVolume = isfield(state, "v") ; variableIsSpecificVolume = isequal(variableName, "v") ; specificVolume = variableIsSpecificVolume || stateHasSpecificVolume ; if specificVolume equation.variableNames = ["p" "v" "R" "T"] ; equation.exponents = [ 1 1 -1 -1 ] ; else equation.variableNames = ["p" "V" "m" "R" "T"] ; equation.exponents = [ 1 1 -1 -1 -1 ] ; end allVariables = joinStructs(state, gas) ; variable = getVariableFromAlgebricEquation(variableName, allVariables, equation) ; end