loop in dsolve code needed

1 view (last 30 days)
MINATI PATRA
MINATI PATRA on 27 Apr 2021
Commented: MINATI PATRA on 28 Apr 2021
D = 10; R = 0.5; a = 0.1; b = 0.5; A = 1.5; B = 1; C = 1; P = 7; xb = 5; N = 5;
syms x f0(x) g0(x) f(k) g(k)
eqn0 = [ diff(f0,3) == 0, diff(g0,2) == 0 ];
cond0 = [ f0(0) == 0, subs(diff(diff(f0)),0) == -2/C, subs(diff(f0),xb) == 0, g0(0) == 1, g0(xb) == 0 ];
F0 = dsolve(eqn0,cond0); f0 = F0.f0; g0 = F0.g0;
for k = 1:N
eqn1 = [ a*diff(f(k),3) + b*(f(k-1)*diff(f(k-1),2) - diff(f(k-1))^2 ) - D*diff(f(k-1)) == 0,...
diff(g(k),2) + P*B*( f(k-1)*diff(g(k-1)) - 2*diff(f(k-1))*g(k-1) ) + 3*R*A*g(k-1)^2*diff(g(k-1)) == 0];
cond1 = [ subs(f(k),0) == 0, subs(diff(diff(f(k))),0) == 0, subs(diff(f(k)),xb) == 0, subs(g(k),0) == 0, subs(g(k),xb) == 0 ];
F1 = dsolve(eqn1,cond1); fk = F1.f(k); gk = F1.g(k);
end
f = sum(fk,k,1,N); g = sum(gk,k,1,N);
%% Any contribution in loop formation will be appreciated
  1 Comment
MINATI PATRA
MINATI PATRA on 28 Apr 2021
Dear Walter if you have some time to spend here will be helpful!
Thank you

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!