我正在尝试使用ODE45 MATLAB解决一个非线性微分方程系统,我做了很多次成功,但这次我得到以下错误,我真的不知道什么是错的,我很困惑。这是代码。
%%这是错误:
$('document').ready(function() {
$("#login-form").on("submit", (function(e) {
e.preventDefault();
var data = $("#login-form").serialize();
$.ajax({
type: 'POST',
url: 'login-response.php',
data: data,
success: function(response) {
console.log(response.length);
if (response == true) {
$("#btn-login").html('<img src="btn-ajax-loader.gif" /> Signing In ...');
setTimeout(' window.location.href = "demo.php"; ', 4000);
} else {
$("#error").fadeIn(1000, function() {
$("#error").html('<div class="alert alert-danger"> <span class="glyphicon glyphicon-info-sign"></span> ' + response + ' !</div>');
$("#btn-login").html('<span class="glyphicon glyphicon-log-in"></span> Sign In');
});
}
}
});
}));
});
%%方程式在函数中定义:
session_start();
$user_email = $_POST['user_email'];
$user_password = $_POST['password'];
if ($user_email == 'admin' && $user_password == '123') {
$_SESSION['user_session'] = $user_email;
echo json_encode(true);
}
else {
echo "email or password does not exist."; // wrong details
}
%%,这里函数被ODE45调用来解决:
Subscript indices must either be real positive integers or logicals.
Error in non_L_ss (line 6)
(-Fk*(ds0+x(3)-x(1))+Fk*ds0-Fc(x(4)-x(2)))/ms +Fa/ms ] ;
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed,solver_name,ode, tspan,y0,optio varargin);
Error in solve (line 50)
[t X]=ode45(@non_L_ss,t_span,IC);
答案 0 :(得分:1)
Subscript indices must either be real positive integers or logicals.
Error in non_L_ss (line 6)
(-Fk*(ds0+x(3)-x(1))+Fk*ds0-Fc(x(4)-x(2)))/ms +Fa/ms ] ;
表示您将某些内容用作具有非整数索引的索引数组。这可能意味着该对象根本就没有数组。我建议更换
Fc(x(4)-x(2))
通过
Fc*(x(4)-x(2))
试图解决这个问题。