Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
定义函数im matlab(symfun)的不同情况_Matlab - Fatal编程技术网

定义函数im matlab(symfun)的不同情况

定义函数im matlab(symfun)的不同情况,matlab,Matlab,我想创建一个函数(symfun),我想把它分为几类,即如果t>那么答案将是a,如果t不确定我是否理解你想要的。 此代码“组合”了以下定义的函数symfun和xt+otot_q3: function test; m=randn(4); % N(0,1) random numbers l=xtotot_q3(symfun(0,m)) % combine xt_otot_q3 and symfun l=symfun(0,xtotot_q3(m)) % c

我想创建一个函数(symfun),我想把它分为几类,即如果t>那么答案将是a,如果t不确定我是否理解你想要的。 此代码“组合”了以下定义的函数symfun和xt+otot_q3:

function test; 
  m=randn(4);               % N(0,1) random numbers
  l=xtotot_q3(symfun(0,m))  % combine xt_otot_q3 and symfun 
  l=symfun(0,xtotot_q3(m))  % combine symfun and 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;            % some function, in this case 3 * input + 1 
return
功能测试;
m=randn(4);%N(0,1)随机数
l=xtotot_q3(symfun(0,m))%xt_otot_q3和symfun组合
l=symfun(0,xtotot_q3(m))%将symfun和xtotot_q3结合起来
返回
函数lval=symfun(thr,rval);
lval=个(大小(rval));%输出,输入的大小,=1

利瓦尔(rvalhi,我确实保存了它并运行了它,问题是我在运行它之后没有得到任何函数…我的意思是没有我可以计算的lval…你知道为什么吗?你可以将第一行更改为
function l=test;
——如果你在matlab中键入
test
,第二行
l
将作为
ans
返回。或者如果你pe
l=test
返回为
l
。如果您想要第一个
l
而不是第二个,可以更改以
l=…
开头的两行的顺序
function [x1] = xt_otot_q3(t)
>> l(m) = xt_otot_q3(m)
Conversion to logical from sym is not possible.
function test; 
  m=randn(4);               % N(0,1) random numbers
  l=xtotot_q3(symfun(0,m))  % combine xt_otot_q3 and symfun 
  l=symfun(0,xtotot_q3(m))  % combine symfun and 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;            % some function, in this case 3 * input + 1 
return