switch

Parent Previous Next

switch





switch expression_ref



 case expression1



  ...



 case expression2



  ...



 otherwise



  ...



end


Notes

  • expression can be a scalar, vector, string, or an audio object.

Examples

Suppose a user-defined function is defined as following:

function out = test_switch(in)
switch in
 case 99
  out=9999;
 case "bj"
  out=in++"kwon";
 case tone(440,10)@-20
  out=in.rms;
 case noise(30)
  out="you can never have this output.";
 otherwise
  out="Not one of prepared input items.";
end

In the AUXLAB workspace:

AUX> test_switch(99)

ans =
 9999

AUX> test_switch("bj")

ans =
 "bjkwon"

AUX> test_switch(tone(440,5+5)@-20)

ans =
 -20

AUX> test_switch(99.0001)

ans =
 "Not one of prepared input items."

AUX> test_switch(noise(30))

ans =
 "Not one of prepared input items."

Created with the Personal Edition of HelpNDoc: Free iPhone documentation generator