MATLAB画出sigmoid函数
| 分类: matlab学习 |
% MATLAB r2014a 代码无误
图像如下:
代码如下:
clear all;close all;clc
t=4;
x=-t:0.1:t;
y=1./(1+exp(-x));%sigmoid函数
plot(x,y,'r','LineWidth',2)
%画图,并设置颜色是红色,线粗为2
annotation('arrow',[0.1 0.9],[0.517
0.517],'color','b');%画横向箭头,为何取[0.1 0.9],[0.517 0.517]还不明白
annotation('arrow',[0.517
0.517],[0.1 0.9],'color','k');%画纵向箭头
set(gcf,'color','w');%设置figure窗口颜色为白色,默认为灰色
legend('sigmoid',2);%添加图例,默认右上角,可选1、2、-1等
title('f=sigmoid');%添加标题

加载中…