Filter löschen
Filter löschen

Defining functions with exponentials

1 Ansicht (letzte 30 Tage)
Honey Adams
Honey Adams am 13 Jul. 2018
Kommentiert: Honey Adams am 13 Jul. 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)

Akzeptierte Antwort

Florian Floh
Florian Floh am 13 Jul. 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 Kommentar
Honey Adams
Honey Adams am 13 Jul. 2018
you saved my life Florian.:).I went through over ten times.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by