MATLAB: Variables with especific posible values

especific posible values

Hi, i'm trying to define some variables that only can take one of some defined values, and depending of wich value results for this variable, other variabe take a value. for example:
i have this variable: Capext, this must take one of this values :
/0,50,95,120/
and if Capext = 0, then Cuext = 0 and Cauext = 0
Capext = 50, then Cuext = 0.6 and Cauext = 570
Capext = 95, then Cuext = 0.8 and Cauext = 900
Capext = 120, then Cuext = 1.1 and Cauext = 1030
i don't know how to use or define as variables that three. i´ve tried to define a set ( i /1*4/) and the variables as parameters depending of "i", but it didn't work. i've tried to define all that as a table but now i think it's not possible, because i need that as variables, and i need to know which value is taken for the model.
i would be grateful if one you can help me.

Best Answer

One way to approach your problem:
CapextResult = @(Capext) ((Capext == 0)*[0 0] + (Capext == 50)*[0.6 570] + (Capext == 95)*[0.8 900] + (Capext == 120)*[1.1 1030]);
CapextVct = [0,50,95,120];
for k1 = 1:length(CapextVct)
CapextTest(k1,:) = CapextResult(CapextVct(k1));
end
Related Question