Failure in initial objective function evaluation. FSOLVE cannot continue.

Function File
function [G]=SteadyStateMillFUN(X)
%These are the algebraic equations for solving the steady-state mill
%balance
global S1 S2 S3 DB21 DB31 DB32 DB41 DB42 DB43 F X0 V rho
XF1=X(1);
XP1=X(2);
XP2=X(3);
XP3=X(4);
XP4=X(5);
P=X(6);
R1=X(7);
R2=X(8);
R3=X(9);
R4=X(10);
XF2=0;
XF3=0;
XF4=0;
G=[1-(XF1+XF2+XF3+XF4);
1-(XP1+XP2+XP3+XP4);
F*XF1-P*XP1 + R1;
F*XF2-P*XP2 + R2;
F*XF3-P*XP3 + R3;
F*XF4-P*XP4 + R4;
-S2*XP2+XP1*S1*DB21-R2/rho/V;
-S3*XP3+XP1*S1*DB31+XP2*S2*DB32-R3/rho/V;
XP1*S1*DB41+XP2*S2*DB42+XP3*S3*DB43-R4/rho/V;
R1+R2+R3+R4];
end
CODE TO RUN FUNCTION FILE
clear all;close all;clc
global S1 S2 S3 DB21 DB31 DB32 DB41 DB42 DB43 F X0 V rho
S1=.03;
S2=.02;
S3=.01;
DB21=1/3;
DB31=1/3;
DB32=.5;
DB41=1/3;
DB42=.5;
DB43=1;
V=20;
F=1;
rho=1500;
%tf=200;
%X0=[0.80 0.1 0.1 0];
Xguess=[1, 0, 0, 0, 0, 1, 0, 0, 0, 0];
Xguess=Xguess';
%OPTIONS = odeset('AbsTol',1e-8,'RelTol',1e-8); %Sets tolerences
%[t,X] = ode15s(@MillModelFUN,[0:.03:tf],X0,OPTIONS); %Solves diff e for the milling
[X,FVAL]=fsolve(@SteadyStateMillFUN,Xguess)
FVAL
X
%sprintf('Feed in Bin 1=%8.5f\nProduct in Bin 1=%8.5f\nproduct in Bin 2=%8.5f\nproduct in Bin 3=

댓글 수: 3

Works fine for me, although I recommend that you get rid of the global variables.
FVAL =
1.0e-12 *
0
0
0.1030
0.1174
0.3507
-0.5999
-0.0000
-0.0000
-0.0000
0.0001
X =
1.0000
0.0011
0.0006
0.0017
0.9967
1.0000
-0.9989
0.0006
0.0017
0.9967
what could be causing the problem on my laptop?
got it to run. thanks

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2018년 10월 16일

댓글:

2018년 10월 16일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by