I am having problems finding the roots of the following non linear discontinuous equation
Show older comments
Below is the code I am using, and the error message I recieve:
function y = firstorder(x)
mat = 'mnfepas';
props = material_data(mat);
S = props(1,3);
L = props(1,4);
J = props(1,5);
Tc = props(1,6);
Ns = props(1,8);
g = props(10);
T = 200;
B = 1;
muB = 9.27e-24; % units: Am^2 or J/T
kB = 1.3807e-23; % units: J/K
nu = 1.75;
y = (1/T)*(3*Tc*J*((0.5/J)*((2*J+1)*coth((J+0.5)*x/J)-coth(0.5*x/J)))/(J+1) + g*muB*J*B/kB + (9/5)*(((2*J+1)^4)-1)*Tc*nu*(((0.5/J)*((2*J+1)*coth((J+0.5)*x/J)-coth(0.5*x/J)))^3)/((2*J+2)^4))-x;
end
Then I use the following:
x0 = 3;
x = fzero(firstorder,x0);
And then I get the following error message:
Error using firstorder (line 21) Not enough input arguments.
Error in nonlinear_brillouin_solver (line 2) x = fzero(firstorder,x0);
the function y is discontinuous at zero due to the coth, and at some values of T the function will cross the x axis multiple times, so I should get multiple roots... i think
Any help would be greatly appreciated
Accepted Answer
More Answers (1)
Youssef Khmou
on 17 Jul 2013
hi David,
if you have numerical values of the coefficients, you can use the function root instead as in this example :
6 x^3 - 4 x^2 + 10 x + 6 =0
R=roots([6 -4 10 6])
Categories
Find more on Quadratic Programming and Cone Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!