Matlab:警告:矩阵奇异、接近奇异或缩放不良。结果可能不准确。RCOND=NaN。

Matlab:警告:矩阵奇异、接近奇异或缩放不良。结果可能不准确。RCOND=NaN。,matlab,warnings,Matlab,Warnings,在我的matlab程序中: % Orto-xylene oxidation in an adiabatic PFR. % ethylbenzene -> Anhydrated-xylene + H2 % There is water as an inert in the system global y0 F0 deltaHR0 P0 ni n y0(1) = 0.0769; % ethylbenzene y0(2) = 0.; % styrene y0(3) = 0.; % hydrog

在我的matlab程序中:

% Orto-xylene oxidation in an adiabatic PFR.
% ethylbenzene -> Anhydrated-xylene + H2
% There is water as an inert in the system
global y0 F0 deltaHR0 P0 ni n 
y0(1) = 0.0769; % ethylbenzene
y0(2) = 0.; % styrene
y0(3) = 0.; % hydrogen
y0(4) = 0.923; % water
Feed  = 1105.; % F01 + FH2O Feed rate [mol/s]
F0 = Feed .* y0; % Inlet feed rate of components [mol/s]
Tin = 925.;
n = 4.;        % Number of reacting compound
deltaHR0 = 124850.; % heat of reaction at standard conditions[J/mol]
P0 = 240000.; % pressure [Pa]
W = 25400.; % reactor weight [kg]
ni = [-1 1 1 0]; % Stoichiometric matrix
% Initial conditions (feed and T0)
u0 = F0;
u0(n+1) = Tin;
wspan = [0 W];
[w_adiab,u] = ode15s(@dfuns,wspan,u0);
conv_adiab = 1 - u(:,1)/F0(1);
T = u(:,n+1);
subplot(2,1,1)
plot(w_adiab,conv_adiab,'-')
title('Conversion profile')
grid on
xlabel('W')
ylabel('X(A1)')
subplot(2,1,2)
plot(w_adiab,T,'-')
title('Temperature profile')
grid on
xlabel('W')
ylabel('T')

%function file dfuns 
function f = dfuns (w,U)
global y0 F0 deltaHR0 P0 ni n 
% U(1) = F1
% U(2) = F2
% U(3) = F3
% U(4) = F4
% y is a vector of n components 
y = U(1:n)/sum(U(1:n)); % molar fractions
T = U(n+1);
k = 3.46* 10e8.* exp(-10980./T); %Needs to be in Pascal 
K = 8.2.* 10e11.* exp(-15200./T); %Needs to be in Pascal 
rm  = k.* (y(1)* P0- (y(2).* y(3).*(P0^2))./ K);
f(1:n) = -ni(1:n).* rm;
Cp1 = 37.778 + 87.940e-3.* T + 113.436e-5.* T^2; % ethylbenzene 
%Cp2 = 71.201 + 54.706e-3.* T + 64.791e-5.* T^2; % styrene 
%Cp3 = 23.969 + 30.603e-3.*T - 6.418e-5.* T^2; % hydrogen 
Cp4 = 36.540 - 34.827e-3.*T + 11.681e-5.*T^2; % water 
deltaCp = 0.;
% deltaCp considered to be different from zero
% deltaCp = -Cp1+Cp2+Cp3;
deltaHR = deltaHR0;
% non-const deltaHR
% T0=273.5;
% deltaHR = - deltaHR0 + (37.778.* T + 87.940e-3.* (T^2)./2 +...
%    113.436e-5.* (T^3)./3) + (71.201.* T + 54.706e-3.* (T^2)./2 + ...
%    64.791e-5.* (T^3)/3) + (23.969.*T + 30.603e-3.* (T^2)./2 -...
%    6.418e-5.* (T^3)/3) - (37.778*T0 - ...
%    87.940e-3.*(T0^2)./2 + 113.436e-5.* (T0^3)./3 )+...
%    (71.201 * T0 + 54.706e-3.* (T0^2)./2 + 64.791e-5.* ...
%    (T0^3)./3) + (23.969 * T0 + 30.603e-3.* (T0^2)./2 -...
%    6.418e-5.* (T0^3)./3);
f(n+1) = (1./((F0(1)+F0(4)).* (y0(1).* Cp1 + y0(4).* Cp4 +y(1).* deltaCp)*...
    (1 - U(1)/F0(1)))).*-deltaHR.* rm;
f = f'; % transformation to column vector
由于forrowing警告,我遇到了一个问题:

In catPFR (line 21) 
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN. 
> In ode15s (line 589)
  In catPFR (line 21) 
Warning: Failure at t=0.000000e+00.  Unable to meet integration tolerances without reducing the step size below the
smallest value allowed (7.905050e-323) at time t. 
> In ode15s (line 668)
  In catPFR (line 21)
谁能帮帮我吗?这个问题可能是函数中的一个错误,但我对matlab的了解还不够。当然,我没有得到我所期望的图表

多谢各位


Serena

如果您在集成过程中检查函数dfuns(w,U)的返回值,您将看到在大多数情况下它包含NaN或Inf。当然,在这种情况下,
ode15s
无法继续。检查
dfuns
并确保它返回正确的值。

您期望的图形是什么?请正确解释该程序代表什么,您指的是哪篇文章以及期望的图形是什么?不要像这样发布代码,因为它很难遵循。