I get error when I try to plot sigmoid function
이전 댓글 표시
I try to plot equation with sigmoid function, but i get error
M1(1)=0;
t(1)=0;
h=0.01;
dt=-30:h:30;
t=zeros(length(dt),1);
M1=zeros(length(dt),1);
for i= 1:length(t)
t(i+1)=t(i)+dt;
M1(i+1)=M1(i)+1./(1+exp(-dt));
end
plot(t,M1);
채택된 답변
추가 답변 (2개)
A pure sigmoidal logistic function looks like this

x = linspace(-10, 10, 20001);
S = 1./(1 + exp(-x));
figure(1)
plot(x, S), grid on
title('Sigmoidal Logistic function')
xlabel('x')
But yours looks like the ReLU-like (rectified linear unit) activation function due to the Iterative addition of M1(i). Can you clarify the type of sigmoid function that you are looking for?
M1(1) = 0;
t(1) = 0;
h = 0.01;
dt = -30:h:30;
t = zeros(length(dt), 1);
M1 = zeros(length(dt), 1);
for i= 1:length(t)
t(i+1) = t(i) + dt(i);
M1(i+1) = M1(i) + 1./(1+exp(-dt(i)));
end
figure(2)
plot(dt, M1(2:end)), grid on
title('ReLU-like function')
xlabel('dt')
Walter Roberson
2023년 5월 9일
dt=-30:h:30;
dt is a vector
t(i+1)=t(i)+dt;
t(i) is a scalar. Add the complete vector dt and you will get a vector. But you cannot store a vector in the scalar location t(i+1)
댓글 수: 4
It is really strange to have time go backwards:
h=0.01;
dt=-30:h:30;
t = cumsum(dt);
plot(t)
I suspect you want t itself to be -30 to +30 -- that you want
t(1) = -30;
dt = h;
for i= 1:length(t)
t(i+1)=t(i)+dt;
end
plot(t)
cindyawati cindyawati
2023년 5월 9일
편집: cindyawati cindyawati
2023년 5월 9일
cindyawati cindyawati
2023년 5월 9일
Walter Roberson
2023년 5월 9일
t(i+1)=t(i)+dt(i);
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





