[Scilab-users] case control statement

Stefan Du Rietz sdr at durietz.se
Sun Jan 22 17:35:28 CET 2017



Hello Claus,

you put the parentheses wrong:
      elseif or([model==3 model==4])

Regards
Stefan

On 2017-01-22 17:01, Claus Futtrup wrote:
> Hi there
>
> OK, so I converted to elseif (source code at the bottom of my post).
> Now Scilab complains like this:
>
>     elseif or[(model==3) (model==4)] then // FDD-LOG / CLOG
>              !--error 35
> Syntax error in a 'if' instruction.
> at line      11 of function getq called by :
> endfunction
>
> I'm replacing a CASE control with an ELSEIF and using the OR[] to
> collect my options. I tested the OR control on the command line,
> without problems, so I don't understand what Scilab is complaining about.
>
> Please let me know if you have any idea...
>
> Best regards,
> Claus
>
> Here's a code snippet:
>
> // This function, getq, defines the q-values for all models.
>
> if model==1 then // FDD
>        //
>        // q = 1 - this used to be 1 - beta*ln(w) also for FDD (!?!?)
>     q = 1;
>
> elseif or[(model==3) (model==4)] then // FDD-LOG / CLOG
>          //
>          // q = 1 - beta * ln(w) - Scilab log(w) = natural log = ln(w))
>     q = 1 - gbeta*log(w); // gbeta - it's _not_ LOG model _lambda_
>
> elseif model==2 then // LOG
>        //
>        // q = 1 - beta*ln(iw)
>        //
>     q = 1 - gbeta*log(%i .* w);
>
> end
>
> On 22-01-2017 16:14, Samuel Gougeon wrote:
>> Hello Claus,
>> No it's not possible. It has been suggested here:
>> http://bugzilla.scilab.org/6503
>> But chained /elseif /statements do the same in a fully versatile way.
>> HTH
>> Samuel
>> PS: BTW, i don't really understand the interest in the select/case
>> structure wrt the elseif one.
>> select/case looks stiffer and less powerful.
>>
>> Le 22/01/2017 15:58, Claus Futtrup a écrit :
>>> Hi there
>>>
>>> I'd like to use the "case" control statement to select a few
>>> options. I'm wondering, is it possible for a case to have multiple
>>> options, I mean like this:
>>>
>>> select model
>>>
>>> case 1,3,4 then
>>>
>>>     do something
>>>
>>> case 2 then
>>>
>>>     do something
>>>
>>> case 5 then
>>>
>>>     do something
>>>
>>> end
>>>
>>> Could I define [1 3 4] as a group of options and ask "CASE IN
>>> GROUP" ... or how would I go about and implement this?
>>>
>>> Best regards,
>>>
>>> Claus
>>>
>>> _______________________________________________
>>> users mailing list
>>> users at lists.scilab.org
>>> http://lists.scilab.org/mailman/listinfo/users
>>>
>>
>>
>>
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> http://lists.scilab.org/mailman/listinfo/users
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>




More information about the users mailing list