Exponential approximation for vector input
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Eduardo
el 31 de En. de 2023
Comentada: Eduardo
el 1 de Feb. de 2023
I was double checking the behaviour of a sigmoid function used in my Simulink model and I noticed that I was getting incorrect approximations when I made the computation for a vector of values
vect = [-5.0000 -5.0000 -5.0000 1.0000 0.9000 0.8000 0.7000 -5.0000 -5.0000];
y_vect = 1/(1+exp(-2*(vect'-1)));
% Value calculated using the vector
y_vect(4)
% Value calculated alone
y_val = 1/(1+exp(-2*(vect(4)-1)))
This approximation in my case causes great confussion due to the magnitude of the quantity expected.
Is there any way to solve this?
0 comentarios
Respuesta aceptada
Sulaymon Eshkabilov
el 31 de En. de 2023
You have overlooked one dot. Here is the corrected commands:
vect = [-5.0000 -5.0000 -5.0000 1.0000 0.9000 0.8000 0.7000 -5.0000 -5.0000];
y_vect = 1./(1+exp(-2*(vect-1)));
% Value calculated using the vector
y_vect(4)
% Value calculated alone
y_val = 1/(1+exp(-2*(vect(4)-1)))
Más respuestas (1)
Voss
el 31 de En. de 2023
vect = [-5.0000 -5.0000 -5.0000 1.0000 0.9000 0.8000 0.7000 -5.0000 -5.0000];
Using / (matrix right division), as you have it now:
y_vect = 1/(1+exp(-2*(vect'-1)));
disp(y_vect)
Using ./ (element-wise right division):
y_vect = 1./(1+exp(-2*(vect'-1)));
disp(y_vect)
0 comentarios
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!