Azzera filtri
Azzera filtri

Defining functions with exponentials

1 visualizzazione (ultimi 30 giorni)
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)

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Graphics Object Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by