Not enough input arguments
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ricardo Gasque Ruiz
am 29 Nov. 2020
Kommentiert: Walter Roberson
am 30 Nov. 2020
Hi i have a problem with my code and i do not know how to solve it it says that there is not enough input arguments.
Its say the problem is on line 2
function [x,y,z]=Fun_RungK4(f,g,j,x0,y0,z0,a,b,h)
t = a:h:b;
n = length(t);
x = [x0];
y = [y0];
z = [z0];
for i=1:n-1
k1 = h * f(x(i), y(i), z(i), t(i));
l1 = h * g(x(i), y(i), z(i), t(i));
m1 = h * j(x(i), y(i), z(i), t(i));
k2 = h * f(x(i) + (k1/2), y(i) + (l1/2), z(i) + (m1/2), t(i) + (h/2));
l2 = h * g(x(i) + (k1/2), y(i) + (l1/2), z(i) + (m1/2), t(i) + (h/2));
m2 = h * j(x(i) + (k1/2), y(i) + (l1/2), z(i) + (m1/2), t(i) + (h/2));
k3 = h * f(x(i) + (k2/2), y(i) + (l2/2), z(i) + (m2/2), t(i) + (h/2));
l3 = h * g(x(i) + (k2/2), y(i) + (l2/2), z(i) + (m2/2), t(i) + (h/2));
m3 = h * j(x(i) + (k2/2), y(i) + (l2/2), z(i) + (m2/2), t(i) + (h/2));
k4 = h * f(x(i) + k3, y(i) + l3, z(i) + m3, t(i) + h);
l4 = h * g(x(i) + k3, y(i) + l3, z(i) + m3, t(i) + h);
m4 = h * j(x(i) + k3, y(i) + l3, z(i) + m3, t(i) + h);
x(i + 1) = x(i) + ((h/6) * (k1 + (2*k2) + (2*k3) + k4));
y(i + 1) = y(i) + ((h/6) * (l1 + (2*l2) + (2*l3) + l4));
z(i + 1) = z(i) + ((h/6) * (m1 + (2*m2) + (2*m3) + m4));
end
plot3(t,x,t,y,t,z,'-g')
comet3(x,y,x)
end
3 Kommentare
Walter Roberson
am 30 Nov. 2020
This creates function handles that expect three parameters, but the code passes four parameters to them.
Akzeptierte Antwort
Walter Roberson
am 29 Nov. 2020
You have not shown us the definition of f, g, or j, so we cannot say which of them needs more than the four input arguments you are passing to them.
That said... 95% of the time when someone posts something like this, it is because they have pressed the big green Run button to run the code, instead of going down to the command line and invoking the code passing in parameters.
If you press the big green Run button, MATLAB will not look inside the base workspace to find definitions for f, g, j, x0, y0, z0, a, b, or h: MATLAB relies strictly on the values passed in positionally.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown 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!