Using fsolve to generate an array of answers
Afficher commentaires plus anciens
Hello,
I am trying to solve two simultaneous equations in a for loop and for each iteration I am changing temperature. I would like to generate an array of solutions such that I can plot verse temperature. Each iteration will generate two values associated with T.
A sample of the code is below:
T2=1809:1:2130; R=8.3144621; x3=[0.5,0.5]; %guess ao_s=18340; ao_l=20000; deltaH_Fe=15200; deltaH_Cr=20900; To_Fe=1809; To_Cr=2130;
for i=1:322
fun3=@(X) [(deltaH_Fe.*(To_Fe-T2(i))./To_Fe)./(R.*T2(i))+(ao_l./R.*... T2(i)).*(X(2).^2)-(ao_s./R.*T2(i)).*(X(1).^2)+log((1-X(2))./(1-X(1)))... ;(deltaH_Cr.*(To_Cr-T2(i))./To_Cr)./(R.*T2(i))+(ao_l./R.*T2(i)).*... ((1-X(2)).^2)-(ao_s./R.*T2(i)).*((1-X(1).^2)+log(X(2)./X(1)))];
X_ph=fsolve(fun3,x3);
end
I would like to generate X_ph either as 2x? matrix depending on how many temperature values or instead generate two separate matrix with values for X(1) in one and X(2) in another.I'm also getting an fsolve stalled error with this currently, not sure why this is happening either...
Any help would be greatly appreciated.
Thank you
1 commentaire
Matt Fig
le 3 Nov 2012
There is a little button that looks like this: {} Code
Please use it....
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!