Info

此问题已关闭。 请重新打开它进行编辑或回答。

previous technique didnt work

1 次查看(过去 30 天)
MINATI
MINATI 2019-2-24
评论: MINATI 2019-2-24
function main
clc;clear all;
so=1;
c=-1.25;
% a=1;
Pr=1;
n=2;
x=5;
x1=fsolve(@solver,x);
function F=solver(x)
[t,u]=ode45(@equation,[0,20],[so c 1 x]);
s=length(t);
F=[u(s,2)-1; u(s,4)];
function dy=equation(t,y)
dy=zeros(5,1);
dy(1)=y(2);
dy(2)=y(3);
dy(3)=y(2)^2-y(1)*y(3)-1;
dy(4)=y(5);
dy(5)=Pr*(n*y(2)*y(4)-y(1)*y(5));
end
end
function dy=equation(t,y)
dy=zeros(5,1);
dy(1)=y(2);
dy(2)=y(3);
dy(3)=y(2)^2-y(1)*y(3)-1;
dy(4)=y(5);
dy(5)=Pr*(n*y(2)*y(4)-y(1)*y(5));
end
[t,u]=ode45(@equation,[0,20],[so c 1 x1]);
figure(1)
plot(t,u(:,4),'b-');
hold on
end
ERROR is:
Index exceeds matrix dimensions.
Error in solver/equation (line 22)
dy(4)=y(5);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in (line 14)
[t,u]=ode45(@equation,[0,20],[so c 1 x]);
Error in fsolve (line 230)
fuser = feval(funfcn{3},x,varargin{:});
Error in (line 12)
x1=fsolve(@solver,x);
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
>>

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by