I'm trying to solve an implicit matrix equation with fsolve
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.
Accepted Answer
More Answers (3)
Matt J
on 9 Jun 2013
0 votes
Your code should work as is, even if A and B are matrices instead of scalars.
4 Comments
Matt J
on 9 Jun 2013
Oren Commented:
Thanks! alas, as the function is written now, y is a vector already, with a length the size of x. When i try to set B as a matrix, the multiplication B.*y is erroneous since y is a matrix the size of (size(b),size(x)).
Couldn't understand any of that. Please execute at the command line
>> whos A B x
in the case where A and B are matrix data, so that we can see how big everything is. Then tell us how many equations/unknowns will be processed in a single call to FSOLVE in this case.
Oren
on 10 Jun 2013
Matt J
on 10 Jun 2013
Because you have more or fewer equations than unknowns.
Oren
on 10 Jun 2013
Categories
Find more on Mathematics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!