필터 지우기
필터 지우기

Defining functions with exponentials

조회 수: 1 (최근 30일)
Honey Adams
Honey Adams 2018년 7월 13일
댓글: Honey Adams 2018년 7월 13일
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)

채택된 답변

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by