I have a system of ODEs of this form;
Yi=2*Yi*(Y(i-1)-Y(i+1))-Yi; i=1,2,...n-1;
Please note i,i-1 and i+2 with Y are not index;but subscripts since I can't type subscripts here.
Y(i-1) is known for only Yi(i=1) and
Y(i+1) is known for only Yi(i=n-1)
Initial conditions: Yi(0)=0; for i=1,2,...n-1;
I tried the following codes but got back with errors:
%%Y0 and Yn are known
for i=1:n-1
if i==1
Yt=Y(i+1);
Y=dsolve('DY=2*Y*(Y0-Yt)-Y','Y(0)=0');
elseif i==n-1
Yt1=Y(i-1);
Y=dsolve('DY=2*Y*(Yt1-Yn)-Y','Y(0)=0');
else
Yt1=Y(i-1);
Yt=Y(i+1);
Y=dsolve('DY=2*Y*(Yt1-Yt)-Y','Y(0)=0')
end
end
The following error shows: Error using ==> mupadmex Error in MuPAD command: Index exceeds matrix dimensions.
Error in ==> sym.sym>sym.subsref at 1381 B = mupadmex('symobj::subsref',A.s,inds{:});
Error in ==> testerode at 14 Yt=Y(i+1);
Is there any way to solve this problem using matlab or simulink? Thanks