Problem with fsolve - several errors
古いコメントを表示
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
回答 (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 件のコメント
Hannah Wyatt
2018 年 11 月 6 日
Matt J
2018 年 11 月 6 日
You're welcome, but please Accept-click the answer.
カテゴリ
ヘルプ センター および File Exchange で Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!