📄 fun.m
字号:
%'s','s-shape','5*s-shape','gauss1','gauss2','cos','sin+cos'
function y=fun(x,flag,graph)
a=4; b=3;
switch graph
case 's'
switch flag
case 0
y=x;
otherwise
y=1;
end
case 's-shape'
switch flag
case 0
y=1./(1+exp(-x));
otherwise
y=exp(-x)./(1+exp(-x)).^2;
end
case '5*s-shape'
switch flag
case 0
y=10./(1+exp(-x));
otherwise
y=10.*exp(-x)./(1+exp(-x)).^2;
end
case 'gauss1'
switch flag
case 0
y=exp(-x.^2/a);
otherwise
y=-2/a.*x.*exp(-x.^2/a);
end
case 'gauss2'
switch flag
case 0
y=b+exp(-x.^2/a);
otherwise
y=-2/a.*x.*exp(-x.^2/a);
end
case 'cos'
switch flag
case 0
y=cos(x);
otherwise
y=-sin(x);
end
case 'sin+cos'
switch flag
case 0
y=sin(x)+cos(x);
otherwise
y=cos(x)-sin(x);
end
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -