Problem with fsolve - several errors
Mostra commenti meno recenti
Trying to use fsolve to solve a system of two equations - unknowns are H2 and Ts2.
this is the function:
function [F] = SystemProb1(X)
H2 = X(1);
Ts2 = X(2);
F(1) = 'H2*(w*h*n)*(Ts2-Ta) + Om*(w*h*n)*e*(((Ts2+460)^4)-((Ta+460)^4)) - ((w*h*n)*(Ti-Ts2)/(R1+R))';
F(2) = 'H2-0.19*(Ts2-Ta)^0.33';
end
I am running it by including this line in my script:
[X] = fsolve(@SystemProb1, [0 100]);
with 100 and 0 being my approximate "guesses" for H2 and Ts2.
These are the errors I get:
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
Error in SystemProb1 (line 4)
F(1) = 'H2*(w*h*n)*(Ts2-Ta) +
Om*(w*h*n)*e*(((Ts2+460)^4)-((Ta+460)^4)) -
((w*h*n)*(Ti-Ts2)/(R1+R))';
Error in fsolve (line 242)
fuser = feval(funfcn{3},x,varargin{:});
Error in ProcessHeatingHWProb1 (line 26)
[X] = fsolve(@SystemProb1, [0 100]); %guessed values
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot
continue.
Really trying to figure this out because I modeled it off of how I have used fsolve in other examples but it just won't work! Any help or recommendations are appreciated
Risposte (1)
Remove the quotes from your expressions for F(1) and F(2)
F(1) = H2*(w*h*n)*(Ts2-Ta) + Om*(w*h*n)*e*(((Ts2+460)^4)-((Ta+460)^4)) - ((w*h*n)*(Ti-Ts2)/(R1+R)) ;
F(2) = H2-0.19*(Ts2-Ta)^0.33 ;
2 Commenti
Hannah Wyatt
il 6 Nov 2018
Matt J
il 6 Nov 2018
You're welcome, but please Accept-click the answer.
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!