Dear experts,
I am quite new in MATLAB usage. Recently I have written a code to curvefit my experimental values. However, I am getting issues with insufficient input arguments which seems to be very common. I read through previous similar questions, but could not find a specific solution to the issue.
Tries with the main function
function F = HolzapfelFitting23_new(x,lamda)
1) Passing HolzapfelFitting23_new(x,lamda) in the Command Window gives me: "Not enough input arguments"
2) Whereas, providing HolzapfelFitting23_new(x0,lamda) in the Command Window gives me a different error:
Caused by:
Failure in initial objective function evaluation. LSQCURVEFIT cannot continue
I am not sure if the second step is itself correct. Can anyone please help me trace the error in the attached code to perform curve fit? I am using MATLAB R2020b.
Thank you all very much in advance.
Bests,
AB

3 comentarios

Ankit
Ankit el 2 de Oct. de 2020
have you passed values of x,lamda to your function?
x = [0.01 0.1 0.3]; % some values
lamda(:,1) = [1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0]; % some values
lamda(:,2) = 1./sqrt(lamda(:,1)); % some values
lamda(:,3) = lamda(:,2); % some values
out = HolzapfelFitting23_new(x,lamda);
Ankit
Ankit el 2 de Oct. de 2020
Do you have license for optimisation toolbox? if not please read below answer
https://de.mathworks.com/matlabcentral/answers/486650-equivalent-to-lsqcurvefit-without-the-need-of-the-optimisation-toolbox
aroj bhattarai
aroj bhattarai el 2 de Oct. de 2020
Hello Ankit, Thank you for your prompt response. I did that before using the function. With predefined input valus, calculation of F is okay (graphics confirm). But whenever optimset and lsqcurvefit are activated, initial objective function evaluation fails. Also, changing x0 to x inside the code gives an "unknown function or variable x" in lsqcurvefit usage line.
AB

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Oct. de 2020
Editada: Walter Roberson el 2 de Oct. de 2020

0 votos

1) Passing HolzapfelFitting23_new(x,lamda) in the Command Window gives me: "Not enough input arguments"
In that environment, x is not a variable: x is a function (x.m) or is a static method of a class, and it is being invoked with no arguments by you referencing it.
Check with
which x
class(x)

3 comentarios

aroj bhattarai
aroj bhattarai el 2 de Oct. de 2020
Hello Walter,
With x being used functionally in lsqcurvfit as:
[x,...] = lsqcurvefit('HolzapfelFitting23',x0,lamda,...);
shouldn't it automatically take x0, lambda and other values?
If the issue is due to unrecognized or undefined function x within
function F = HolzapfelFitting23_new(x,lamda)
how is it possible to pass the values for x within HolzapfelFitting23_new function?
I think the problem is not x being unrecognized inside HolzapfelFitting23_new .
I think when you are calling the function by using
HolzapfelFitting23_new(x,lamda)
that at that point that x is a function rather than a variable. I do not mean a function handle, I mean that there is an x.m on your path or that you have import()'d an x or you have a static method named x in a class you have loaded. That is, I suspect that that line is attempting to execute x, and that the execution fails because you are not passing in the parameters the function x expects.
aroj bhattarai
aroj bhattarai el 2 de Oct. de 2020
Thank you Roberson, I looked for other possibility by splitting my entire matlab script into two different files. First file calculates the value of the function F = HolzapfelFitting23_new(x,lamda) with indexed lamda. In second file, I provided all necessary parameters for curvefit, "x0, lamda, sig, lb, ub and options". It gave me what I wished for.
Good weekend!
AB

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 2 de Oct. de 2020

Comentada:

el 2 de Oct. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by