previous technique didnt work
Info
This question is closed. Reopen it to edit or answer.
Show older comments
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 Comment
MINATI
on 24 Feb 2019
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!