MATLAB Answers

loop in dsolve code needed

조회 수: 1(최근 30일)
MINATI PATRA
MINATI PATRA 2021년 4월 27일
댓글: MINATI PATRA 2021년 4월 28일
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
MINATI PATRA
MINATI PATRA 2021년 4월 28일
Dear Walter if you have some time to spend here will be helpful!
Thank you

댓글을 달려면 로그인하십시오.

답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by