Info
This question is closed. Reopen it to edit or answer.
Have a pair of two variable equations, and get the error "Not enough input arguements".
1 view (last 30 days)
Show older comments
Hello:
I am very new to MatLab, and having some issues with a system of two-variable equations. Whenever I try to run the run the script I get the following error: Not enough input arguments.
The script is as follows:
function F=eqns(x)
% p=x(1) and q=x(2)
c = input('input value c');
F(1) = (x(1).^(2).*x(2).^(2).*(x(2).^(2)+x(1).^(2))+c^(2).*(x(1).^(4)-6.*x(1).^(2).*x(2).^(2))-3*c^(4).*(x(1).^(2)-x(2).^(2))-4*c^(6))*sin(x(1)).*sinh(x(2))+2.*x(1).*x(2).*(-x(1).^(2).*x(2)^(2)+3.*c^(2)*(x(1).^(2)-x(2).^(2))-7.*c^(4))*cos(x(1)).*cosh(x(2))-x(1).*x(2).*(x(1).^(4)+x(2).^(4)+2.*c^(2).*(x(2).^(2)-x(1).^(2))+2*c^(4))*cos(2*c);
%
F(2) = 2.*c*x(1).*(3.*x(1).^(2).*x(2).^(2)-x(2).^(4)-c^(2).*(x(1).^(2)+x(2).^(2))+4.*c^(4)).*cos(x(1)).*sinh(x(2))+2*c*x(2)*(x(1).^(4)-3*x(2).^(2)*x(1).^(2)-c^(2)*(x(1).^(2)+x(2).^(2))-4*c^(2))*sin(x(1))*cosh(x(2))+x(1)*x(2)*((x(1).^(2)+x(2).^(2))*(x(1).^(2))-x(1).^(2)+2*c^(2))*sin(2*c);
I would ultimately like to apply fsolve to my system.
As stated previously, I am very new to MatLab and programming in general, so any help, advice, and corrections are greatly appreciated. Thank you in advance.
0 Comments
Answers (1)
Walter Roberson
on 9 Jul 2015
You did not mention how you are invoking the code. You need to run it from the command line or from a different line of code and you need to pass in a vector of two values such as
eqns(rand(2,1))
To use the code with fsolve you should rewrite it to not prompt for c...
function F=eqns(x, c)
And then
c=input('what c? ')
fsolve(@(x) eqns(x, c), x0)
2 Comments
Walter Roberson
on 11 Jul 2015
function eqns_driver
c = input('input value c');
x0 = rand(2,1); %replace with initial conditions appropriate for your purpose
result = fsolve(@(x) eqns(x, c), x0);
end
Put the above in eqns_driver.m
The below should go in eqns.m
function F=eqns(x)
% p=x(1) and q=x(2)
F(1) = (x(1).^(2).*x(2).^(2).*(x(2).^(2)+x(1).^(2))+c^(2).*(x(1).^(4)-6.*x(1).^(2).*x(2).^(2))-3*c^(4).*(x(1).^(2)-x(2).^(2))-4*c^(6))*sin(x(1)).*sinh(x(2))+2.*x(1).*x(2).*(-x(1).^(2).*x(2)^(2)+3.*c^(2)*(x(1).^(2)-x(2).^(2))-7.*c^(4))*cos(x(1)).*cosh(x(2))-x(1).*x(2).*(x(1).^(4)+x(2).^(4)+2.*c^(2).*(x(2).^(2)-x(1).^(2))+2*c^(4))*cos(2*c);
%
F(2) = 2.*c*x(1).*(3.*x(1).^(2).*x(2).^(2)-x(2).^(4)-c^(2).*(x(1).^(2)+x(2).^(2))+4.*c^(4)).*cos(x(1)).*sinh(x(2))+2*c*x(2)*(x(1).^(4)-3*x(2).^(2)*x(1).^(2)-c^(2)*(x(1).^(2)+x(2).^(2))-4*c^(2))*sin(x(1))*cosh(x(2))+x(1)*x(2)*((x(1).^(2)+x(2).^(2))*(x(1).^(2))-x(1).^(2)+2*c^(2))*sin(2*c);
end
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!