Given the Cauchy problem
y '= (y-1) ^ 2 (y-2) (y-a) and y(1) = y0;
where a = 0, a = 1 or a = 2:
Write a program that draws the solutions of the problem in different cases. It must comply with the following steps: a) The program will input variable.
b) Divide the viewport into three subplots located in two ... the (two in the first and in the second). Using the command if the first subgraph choose if a = 0, the second if a = 1 and third if a = 2.
c) Create a graph axes fixed size [1, 10] x [-1, 3]. using commands ode45 and plot draw in red fixed points. put axis name and a title graph indicating the case in which we (a = 0, a = 1 or a = 2).
this is my 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 a ~= 0,1,2
disp('must take values 0,1,2')
And the errors:
Error using inline/feval (line 25) Too many inputs to 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 :)