defining different cases for function im matlab (symfun) -
i want create function (symfun), , want divide cases, i.e if t> then answer , if t<0 answer b. thing is, matlab wont allow me put if statements after sym function.
>> l = symfun(0, [m]); >> l(m) = if m>0 3
also tried create function:
function [x1] = xt_otot_q3(t)
and tried connect between 2 functions:
>> l(m) = xt_otot_q3(m) conversion logical sym not possible.
is there way break symfun cases?
not sure understand want. code 'combines' functions symfun , xt+otot_q3 defined below:
function test; m=randn(4); % n(0,1) random numbers l=xtotot_q3(symfun(0,m)) % combine xt_otot_q3 , symfun l=symfun(0,xtotot_q3(m)) % combine symfun , xt_otot_q3 return function lval=symfun(thr,rval); lval=ones(size(rval)); % output, size of input, = 1 lval(rval<thr)=-1; % output = -1 if input < thr return function lval=xtotot_q3(rval); lval=3*rval+1; % function, in case 3 * input + 1 return
you can save whole bit test.m , call test
matlab prompt. maybe if start can modify fit needs.
Comments
Post a Comment