I'm trying to solve an implicit matrix equation with fsolve
2 views (last 30 days)
Show older comments
I'm able to solve an implicit equation with fsolve:
function y = brillouin(x,p)
A=p(1); B=p(2);
y=zeros(size(x));
NN=length(x);
opt=optimset('display','off');
for i=1:NN
y(i)=fsolve(@(y) y-tanh(A.*x(i)-B*y), 1e-9, opt);
end
end
I'm now trying to expand this to a vector y, with B being a matrix. Any help would be appreciated! Thanks.
0 Comments
Accepted Answer
Matt J
on 10 Jun 2013
Edited: Matt J
on 10 Jun 2013
yet, and that is the problem, that the solutions, y(i,x) from fsolve are identical for each of the i=1:6.
That's because you are calling FSOLVE with a scalar initial point 1e-9. FSOLVE is therefore returning scalars.
If FSOLVE is supposed to be returning something in R^6, you must feed it an initial point that is in R^6.
0 Comments
More Answers (3)
Matt J
on 9 Jun 2013
Your code should work as is, even if A and B are matrices instead of scalars.
4 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!