Cannot use fzero on a previously defined function. Am I doing something wrong?
Afficher commentaires plus anciens
I'm having trouble using fzero on this function:
function out = f(theta)
L1 = 2; L2 = sqrt(2); L3 = sqrt(2);
g = pi/2;
p1 = sqrt(5); p2 = sqrt(5); p3 = sqrt(5);
x1 = 4; x2 = 0; y2 = 4;
A2 = L3*cos(theta) - x1;
B2 = L3*sin(theta);
A3 = L2*cos(theta + g) - x2;
B3 = L2*sin(theta + g) - y2;
D = 2*(A2*B3 - B2*A3);
N1 = B3*(p2^2 - p1^2 - A2^2 - B2^2) - B2*(p3^2 - p1^2 - A3^2 - B3^2);
N2 =-A3*(p2^2 - p1^2 - A2^2 - B2^2) + A2*(p3^2 - p1^2 - A3^2 - B3^2);
out = N1^2 + N2^2 - (p1^2)*(D^2);
What I'm doing is inputting this in the command window:
>> fzero(f,-1)
I have saved the function in an m-file as 'f.m'. And I'm obtening the following error:
Not enough input arguments.
Error in f (line 8)
A2 = L3*cos(theta) - x1;
Am I doing something wrong? I will attach the m-file just in case.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Variables dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!