Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Not enough input arguments

1 Ansicht (letzte 30 Tage)
Arslan Kurmashev
Arslan Kurmashev am 5 Mai 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
My code is:
eq=@eqq;
CF=@(u,t, eq)(eq(u,q44, t, t1)*1000*eq(u,q44, t, t1) + u'*1*u);
J=integral(CF,0,T);
where eqq is handwritten function in separate file:
function eqq1 = eqq(u,q44, t, t1)
tdif = intmax;
ideal = 0;
for i=1:length(t)
if (tdif>abs(t(i)-t1))
tdif = abs(t(i)-t1);
ideal = i;
end
eqq1 = q44(ideal);
end
after running my code, I get error in line
CF=@(u,t, eq)(eq(u,q44, t, t1)*1000*eq(u,q44, t, t1) + u'*1*u);
It says that error is following:
Not enough input arguments.
Error in costfunctionalone>@(u,t,eq)(eq(u,q44,t,t1)*1000*eq(u,q44,t,t1)+u'*1*u)
How to solve that problem?
  1 Kommentar
James Tursa
James Tursa am 14 Mai 2019
eq is the name of the built-in element-wise "equals" operator in MATLAB. I would strongly advise you pick a different variable name.

Antworten (1)

Adam Danz
Adam Danz am 5 Mai 2019
Bearbeitet: Adam Danz am 14 Mai 2019
The integral function integrates your function from u=0 to u=T but you never provide values for "t" or "eq" which are the 2nd and 3rd inputs to your function CF.
Follow this example to numerically integrate a parameterized function.
It will look something like this:
J=integral(@(x)CF(x,t,eq),0,T);
where t and eq are constants you provide as the 2nd and 3rd inputs to CF().

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by