with exercise in Matlab -
given cauchy problem
y '= (y-1) ^ 2 (y-2) (y-a) , y(1) = y0;
where = 0, = 1 or = 2:
write program draws solutions of problem in different cases. must comply following steps: a) program input variable.
b) divide viewport 3 subplots located in 2 ... (two in first , in second). using command if first subgraph choose if = 0, second if = 1 , third if = 2.
c) create graph axes fixed size [1, 10] x [-1, 3]. using commands ode45 , plot draw in red fixed points. put axis name , title graph indicating case in (a = 0, = 1 or = 2).
this resolution:
function exercise6(a) disp('partb') f=inline('(y-1)^2*(y-2)(y-a)','y','a'); if a==0 subplot(2,2,1) hold on end if a==1 subplot(2,2,2) hold on end if a==2 subplot(2,2,3) hold on end disp('partc') %f=inline('(y-1)^2*(y-2)(y-a)','y','a'); linspace(-1,3,50) axis([-1,3,1,10]) [t,y]=ode45(inline('(y-1)^2*(y-2)(y-a)','y','a'),'0'); [t2,y2]=ode45(inline('(y-1)^2*(y-2)(y-a)','y','a'),'1'); [t3,y3]=ode45(inline('(y-1)^2*(y-2)(y-a)','y','a'),'2'); plot(t,y,'r') plot(t2,y2,'r') plot(t3,y3,'r') if ~= 0,1,2 disp('must take values 0,1,2')
and errors:
error using inline/feval (line 25) many inputs inline function.
error in odearguments (line 38) [def_tspan,def_y0,def_options] = feval(ode,[],[],'init',extras{:});
error in ode45 (line 114) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeargs, odefcn, ...
error in ejercicio6 (line 23) [t,y]=ode45(inline('(y-1)^2*(y-2)(y-a)','y','a'),'0');
any solution please?
thanks :)
there multiple error lines shown, comes down top one. created invalid inline statement.
if want fix need search:
inline('(y-1)^2*(y-2)(y-a)','y','a')
i don't know inline, guess y
, a
not belong inside inline statement.
Comments
Post a Comment