I'm trying to solve an implicit matrix equation with fsolve
Mostra commenti meno recenti
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.
Risposta accettata
Più risposte (3)
Matt J
il 9 Giu 2013
0 voti
Your code should work as is, even if A and B are matrices instead of scalars.
4 Commenti
Matt J
il 9 Giu 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
il 10 Giu 2013
Matt J
il 10 Giu 2013
Because you have more or fewer equations than unknowns.
Oren
il 10 Giu 2013
Categorie
Scopri di più su Mathematics in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!