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.
>>
  1 件のコメント
MINATI
MINATI 2019 年 2 月 24 日
ERROR is included below the code

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by