[q1, q2, q3, q4]=buckBoostControl(inputVoltage)
function [q1, q2, q3, q4] = buckBoostControl(inputVoltage, ~, ~)
dutyCycleBoost = [85.71, 81.82, 60.00];
delayBoost = [51.444, 65.448, 144.000];
if inputVoltage == 0.3 || inputVoltage == 0.4 || inputVoltage == 1.2
dutyCycle = dutyCycleBoost(inputVoltage == [0.3, 0.4, 1.2]);
delay = delayBoost(inputVoltage == [0.3, 0.4, 1.2]);
dutyCycle = dutyCycleBuck;
error('Input voltage is out of the specified range.');
The function is ok in MATLAB although
if inputVoltage == 0.3 || inputVoltage == 0.4 || inputVoltage == 1.2
is very problematical in doing exact comparisons with floating point values; internal rounding of even the last significant digit away from the value converted from the text representation to internal representation will be sufficient for the comparison to fail when running and the inputVoltage value is not input manually as in the above.
More robust would be
if any(ismembertol(inputVoltage,BOOST_V));
See ismembertol for details and how to set the "nearness" to a match for comparison; the above default will be at about 1E-12 or roughly three digits of precision of a double precision floating point value. How close to the actual values the computation will return will depend upon just how the inputVoltage value is calculated. As for the syntax error, it appears that Simulink (I presume?) looks at code with a jaundiced eye and if it can't determine the shape of anything internally, it throws up its hands.
Try the following rearrangement of the code which is also just a little more efficient as it doesn't do the lookup indexing twice...
ix=ismembertol(inputVoltage,BOOST_V));
dutyCycle = dutyCycleBoost(ix);
and see if that will satisfy...