Borrar filtros
Borrar filtros

Defining functions with exponentials

1 visualización (últimos 30 días)
Honey Adams
Honey Adams el 13 de Jul. de 2018
Comentada: Honey Adams el 13 de Jul. de 2018
I defined the function below in Matlab where my parameters are x and constants v, data, t. I tried to test the function but the function generates errors relating to the exponents. Attached is an image of the function. P*m*((1-e^(-(p+(q_m q_0)/(q_(0+) (q_m-q_0)e^(-vw) ))*t)))/(P+ ((q_m q_0)/(q_(0+) (q_m-q_0)e^(-vw) ))*e^(-(P+ ((q_m q_0)/(q_(0+) (q_m-q_0 ) e^(-vw) ))*t) )
function res= Bass(x,v,data ,t)
%objective function
F=[-data + (x(1)*x(2)*((1- exp*(-x(1)-((x(3)*x(4))/(x(4)+(x(3)-x(4))*exp(-x(5)*v))))*t)/...
(x(1) + ((x(3)*x(4)) / (x(4)+((x(3)-x(4))*exp(-x(5)*v)))) * exp(-x(1) - ((x(3)*x(4)) /( x(4)+(x(3)-x(4))*exp(-x(5)*v))))*t)))];
res=sum(F.^2)

Respuesta aceptada

Florian Floh
Florian Floh el 13 de Jul. de 2018
In the very first line of your code, you misplaced the '*' (you placed it right after the 'exp' expression. I tried the following code by myself and it worked flawlessly. I hope my answer was helpful.
% This one should work:
F=[-data + (x(1)*x(2)*((1- exp((-x(1)-((x(3)*x(4))/(x(4)+(x(3)-x(4))*exp(-x(5)*v))))*t))/... (x(1) + ((x(3)*x(4)) / (x(4)+((x(3)-x(4))*exp((-x(5)*v)))) * exp(-x(1) - ((x(3)*x(4))) /( x(4)+(x(3)-x(4))*exp((-x(5)*v))))*t))))]; res=sum(F.^2)
  1 comentario
Honey Adams
Honey Adams el 13 de Jul. de 2018
you saved my life Florian.:).I went through over ten times.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Programming 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!

Translated by