Not enough input arguments?
Mostra commenti meno recenti
I'm new to Matlab and I can't for the love of god figure out why there's error.
What's wrong with
y1 = f(1/2,w1,w2);
How isn't there enough input??? There are precisely 3 inputs!!! I've spent 2 hours on this already... Please help!!!!
function main
x = [1;1;1;1;1;1;1];
broyden(x,@F,7,0.001);
end
function y = f(a,b,c)
y = -a + 2 * b - c + (1/8)^2 * 2 * b^3;
end
function y = F(w1,w2,w3,w4,w5,w6,w7)
y1 = f(1/2,w1,w2);
y2 = f(w1,w2,w3);
y3 = f(w2,w3,w4);
y4 = f(w3,w4,w5);
y5 = f(w4,w5,w6);
y6 = f(w5,w6,w7);
y7 = f(w6,w7,1/3);
y = [y1;y2;y3;y4;y5;y6;y7];
end
function [xv,it] = broyden(x,f,n,tol)
it = 0;
xv = x;
Br = eye(n);
fr = feval(f, xv);
while norm(fr) > tol
it = it + 1;
pr = -Br * fr;
tau = 1;
xv1 = xv + tau * pr;
xv = xv1;
oldfr = fr;
fr = feval(f,xv);
y = fr-oldfr;
oldBr = Br;
oyp = oldBr * y - pr;
pB = pr' * oldBr;
for i = 1:n
for j = 1:n
M(i,j) = oyp(i) * pB(j);
end
end
Br = oldBr - M ./ (pr' * oldBr *y);
end
end
The error I get is
Not enough input arguments.
Error in main>F (line 11)
y1 = f(1/2,w1,w2);
Error in main>broyden (line 25)
fr = feval(f, xv);
Error in main (line 3)
broyden(x,@F,7,0.001);
1 Commento
Risposta accettata
Più risposte (1)
Alex Mcaulley
il 3 Giu 2019
In this line:
broyden(x,F,7,0.001);
you are calling the function F without inputs!
Categorie
Scopri di più su Operators and Elementary Operations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!