Filter löschen
Filter löschen

Error using fcnchk (line 106) FUN must be a function, a valid string expression, or an inline function object. Error in fminsearch (line 162) funfcn = fcnchk(fun​fcn,length​(varargin)​);

17 Ansichten (letzte 30 Tage)
Hi,i'm new,it's urgent!
i have this problem: i created a function
function [ q ] = minimizza_x_tau(tc);
load('datinuovi.mat')
fsamp=50;
N=length(Datitermocoppia) ;
t=[0:1/fsamp:N/fsamp-1/fsamp];
salto=max(Datitermocoppia)-min(Datitermocoppia);
y=salto.*(1-exp(-t./tc));
y2=rot90(y);
diffe=(Datitermocoppia-y2).^2;
q=sum(diffe);
end
when i call the function from the script for example with
tc=2;
[taunew]=minimizza_x_tau(tc);
it works, but it is not i have to do.
i have to do a minimization as it:
tc=2;
[q]=fminsearch(minimizza_x_tau(tc),0.24);
If i do that it says me ERRORS above.
you know why? i don't know if put tc=2 is right i put them for example.
thank you

Antworten (1)

Matt J
Matt J am 1 Jun. 2016
You need to pass a handle to the objective function
[q]=fminsearch(@minimizza_x_tau,0.24);

Kategorien

Mehr zu Get Started with Optimization Toolbox 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