Writing a function in MATLAB
Mostrar comentarios más antiguos
I want to simply write this mathemtical equation in MATLAB, but I am getting some error. Please help.
13 comentarios
Sam Chak
el 1 de Oct. de 2023
Would it be possible for you to furnish us with the MATLAB code in question and highlight the specific error that you are encountering? Such information would greatly facilitate our ability to assist you in rectifying the issue at hand.
Click this icon
to insert the MATLAB code.
Kashif Naukhez
el 1 de Oct. de 2023
Editada: Dyuman Joshi
el 1 de Oct. de 2023
Kashif Naukhez
el 1 de Oct. de 2023
Dyuman Joshi
el 1 de Oct. de 2023
Editada: Dyuman Joshi
el 1 de Oct. de 2023
Please attach the excel file so that we can run your code and reproduce the error you obtained.
In your above comment, did you copy and pasted the full error message you got i.e. all of the red text? If not, then copy and paste the full error message.
Additionally, it's not clear to me what the objective of the optimization is? Is it to minimize the sum you have defined or maximize it?
Kashif Naukhez
el 1 de Oct. de 2023
Kashif Naukhez
el 1 de Oct. de 2023
diffun = A*(1-(1-q(1))*beta(1)*x).^(1/1-q(1)) + (1-A)*(1-(lambda/beta(2))+(lambda/beta(1))*exp((q(2)-1)*beta(2)*x)).^(1/1-q(2));
in the term
(1-(1-q(1))*beta(1)*x).^(1/1-q(1))
(1-(1-q(1))*beta(1)*x) --> (1-1+q(1))*beta(1)*x) --> q(1)*beta(1)*x
or is there a typo in the formula as written?
Then the exponent
.^(1/1-q(1)) --> .^(1-q(1))
Was that intended to be
.^(1/(1-q(1)))
instead?
Kashif Naukhez
el 1 de Oct. de 2023
Dyuman Joshi
el 1 de Oct. de 2023
Yes, it was intended as the last line of code you wrote @dpb, as can be seen in the pdf shared by OP.
However the error still persists after making the correction.
I suspect (probably) because optimization is not the way to go here.
Kashif Naukhez
el 1 de Oct. de 2023
Sam Chak
el 1 de Oct. de 2023
The x-data in the 'Double_q.xlsx' spreadsheet is not sorted in ascending order; it appears to resemble an exponential decay when sorted in Excel.

Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Language Support en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!